Method and circuitry for increasing reserve memory in a solid state memory disk

ABSTRACT

A solid state memory disk with increased reserve memory is described. The solid state memory disk includes an array of solid state memory devices for storing user data and reserve memory, which includes both free memory and dirty memory. The solid state memory disk also includes a controller, a clean-up state machine, and a data compressor. The data compressor increases reserve memory by compressing data received from a host and coupling compressed data to the array of memory devices under the control of the controller. In response to write commands from the host, the controller writes a first sector data, which has been compressed, to a first location in a first block within a memory device. Reserve memory within the array is thus increased, so long as the maximum number of sectors the host is allowed to write is less the average compression ratio of the data compressor multiplied by the capacity of the solid state disk. A method of increasing reserve memory in a solid state disk is also described.

FIELD OF THE INVENTION

The present invention relates to a solid state memory disk. Moreparticularly, the present invention relates to a method and circuitryfor increasing reserve memory in a solid state disk to improve theefficiency of clean-up and to improve energy efficiency.

BACKGROUND OF THE INVENTION

Most prior personal computers include many types of memory storagedevices. Hard magnetic disk drives are used for mass memory storage,while different types of semiconductor memories are used for otherpurposes.

The non-volatility of hard magnetic disk drives is one of the chiefreasons for their use. They may be turned on and off without loss ofdata. Hard drives store data on concentric tracks. Each track includesseveral sectors, each of which is typically 512 bytes in length. Readsand writes to magnetic disk drives occur a sector at a time.

A typical user file stored on a magnetic disk drive occupies manysectors, randomly located on the surface of the disk drive. A fileallocation table (FAT) allows location of each sector of the file bystoring a chain of pointers for the file. Each pointer points to thenext sector of the file.

Hard drives suffer from a number of disadvantages. Their size, theirheight in particular, often makes them unattractive for use in portableand lap top computers. The height of a hard disk drive has often beenthe limiting factor in attempts to reduce computer size to makecomputers more portable. Hard drives also consume relatively largeamounts of power, which makes them even less attractive for computersthat are battery powered.

Hard drives are less than ideal for use in computers that will be usedout-of-doors. Magnetic disk drives are extremely sensitive to vibrationand shock. Additionally, magnetic drives cannot tolerate the dust andhumidity associated with much of the great outdoors.

Semiconductor memories, also referred to as solid state memories, do notsuffer from many of the disadvantages of magnetic disk drives. They aresmall and rugged and consume less power than magnetic drives.

One type of non-volatile semiconductor memory is the FLASH electricallyerasable programmable read only memory (FLASH memory). FLASH memoriescan be programmed by the user and once programmed retain their datauntil erased. FLASH memories are rapidly erased by erasing a block ofmemory at a time. A block is a relatively large amount of data,approximately 64 Kbytes or 65,535 bytes.

A FLASH memory cell is erased when net charge is neutral. An erasedFLASH bit is referred to as a logical 1. Conversely, a FLASH memory cellis programmed when the net charge is negative. A FLASH memory cellcannot be reprogrammed without a prior erasure with one exception. AnyFLASH bit can be programmed to a 0 without prior erasure.

In some prior FLASH memories programming and erasure is controlledinternally by a write state machine or a command register. Internalcontrol of programming and erasure lessens the knowledge and timerequired to program and erase the FLASH memories. FLASH erase time timesremain relatively slow despite internal control. Erase cycle time is onthe order one to two seconds. If an erase must occur before every writethen it is not possible to approach magnetic disk drive write timesusing FLASH memory.

SUMMARY OF THE INVENTION

A solid state memory disk with increased reserve memory space isdescribed. The solid state memory disk includes an array of solid statememory devices for storing user data and reserve memory, which includesboth free memory and dirty memory. The solid state memory disk alsoincludes a controller, a clean-up state machine, and a data compressor.

The data compressor increases reserve memory space, thereby improvingclean-up efficiency and power efficiency. In response to write commandsfrom the host, the controller writes compressed data. The controlleralso seeks previous versions of the same sector of data, and marks dirtythat version.

The clean-up state machine generates free memory by erasing blockscontaining dirty memory. The efficiency of clean-up is improved byincreasing the reserve memory. Because compression decreases the averagesector size, more sectors can be written in a given space thereforeblocks are allowed to become dirtier before clean-up is triggered.Because the focus block is dirtier, fewer clean sectors of user datamust be copied out of the focus block during a clean-up.

A method of increasing reserve memory in a solid state disk including adata compressor is also described. The method of increasing reservememory begins by indicating to a host processor a maximum number ofsectors of user data that may be written to the solid state disk. Priorto their storage, sectors of data to be written into the solid statedisk are compressed. The compression of the sectors of data increasesthe reserve memory space so long as the memory capacity allocated to thehost is less than the compression savings returned by the datacompressor. This increase in the reserve memory space reduces the sizeof dirty sectors, thereby increasing the number of dirty sectorsrequired to trigger clean-up. Because the focus block is dirtier,clean-up becomes more efficient because fewer sectors of user data mustbe copied out of the focus block, and those sectors are smaller in size.

An object of the method and apparatus of the present invention is toincrease the reserve memory available for clean-up without increasingthe size of the memory array within the solid state disk.

Another object of the present invention is to improve the efficiency ofclean-up of the solid state disk by reducing the time required toclean-up a focus block.

A further object of the present invention is to improve the efficiencyof clean-up within a solid state disk by reducing the amount of userdata that must be copied during the clean-up of a focus block.

Another object of the present invention is decrease of datafragmentation within a solid state disk.

A still further object of the present invention is to improve the powerefficiency of a solid state disk by reducing the power required toclean-up a focus block.

Other objects, features, and advantages of the present invention will beapparent from the accompanying drawings and the detailed descriptionthat follows.

BRIEF DESCRIPTION OF THE FIGURES

The present invention is illustrated by way of example and notlimitation in the figures of the accompanying drawings in whichreferences indicate similar elements and in which:

FIG. 1 is a block diagram of a personal computer including a solid statememory disk.

FIG. 2 is a block diagram of a solid state memory disk.

FIG. 3 is a block diagram of a block file structure.

FIG. 4 is a block diagram of a first embodiment of the sector headertranslation table.

FIG. 5 is a flow diagram of an algorithm for building a sector headertranslation table upon power-up.

FIG. 6 is an object diagram of the algorithms of the solid state diskcontroller.

FIG. 7 is a flow diagram for a disk read.

FIG. 8 is a flow diagram for seeking a sector of data using a blocksector translation table.

FIG. 9 is a flow diagram for writing a sector.

FIGS. 10A and 10B are a flow diagram of a first method of allocatingmemory space within the FLASH array.

FIG. 11 is a diagram of block chains.

FIGS. 12A and 12B are a flow diagram of a method of allocating memoryspace in response to a write command.

FIG. 13 is a flow diagram of a mark dirty algorithm.

FIG. 14 is a block diagram of the various services within clean-up.

FIG. 15 is a flow diagram for enabling a clean-up state machine.

FIG. 16 is a flow diagram for executing one state of a clean-up statemachine.

FIG. 17 is a flow diagram of the states of a clean-up state machine.

FIG. 18 is a flow diagram of the algorithm for evaluating whetherclean-up should be triggered.

FIG. 19 is a flow diagram of the algorithm for adaptively triggeringclean-up.

FIG. 20 is a flow diagram of the algorithm for choosing a block toclean-up.

FIG. 21 is a flow diagram for allocating memory for clean-up.

FIG. 22 is a flow diagram of a method of allocating free physical memoryfor clean-up.

FIG. 23 is a flow diagram for copying a sector into the sector buffer.

FIG. 24 is a flow diagram for copying part of a sector out of the sectorbuffer and into a destination block.

FIG. 25 is a flow diagram for updating databases after copying a sector.

FIG. 26 is a flow diagram for initiating erasure of a block.

FIG. 27 is a flow diagram for determining whether erasure of a block iscomplete.

FIG. 28 is a flow diagram for updating databases after block erasure.

FIG. 29 is a flow diagram for foreground clean-up.

FIG. 30 is a flow diagram for forcing clean-up.

FIG. 31 is a flow diagram of another way of forcing clean-up.

DETAILED DESCRIPTION

I. Overview of Solid State Disk

FIG. 1 illustrates in block diagram form personal computer 50. Personalcomputer 50 includes central processing unit (CPU) 52 and monitor 54 forvisually displaying information to a computer user. Keyboard 56 allowsthe computer user to input data to CPU 52. By moving mouse 58 thecomputer user moves a pointer displayed on monitor 54. Personal computer50 uses solid state memory disk 60 for mass memory storage, rather thana hard magnetic disk. Solid state disk 60 includes a solid state diskcontroller to control nonvolatile memory array 62. The tasks allottedthe controller 64 include converting dirty memory to free memory viaerasure during clean-up. Nonvolatile semiconductor memory array 62 isalso referred to as FLASH array 62.

The power efficiency and clean-up efficiency of solid state disk 60 isimproved by the appropriate use of data compressor 97. Additionalreserve memory space is generated by compressing user data. Theincreased reserve memory improves clean-up efficiency and powerefficiency.

A. FLASH Array and Block File Structure

A greater understanding of solid state disk controller 64 is aided by anunderstanding of the object of its control, FLASH array 62. The programand erase characteristics of FLASH array 62 strongly influence solidstate disk controller 64. The FLASH devices within FLASH array 62 mustbe erased a block at a time, but can be programmed a byte at a time.Once programmed to a 0, a bit of FLASH memory cannot be programmed to a1 without first erasing an entire block. Erased bytes of memory arereferred to as "free" because they are ready to be written.

Erasure of FLASH memory is a slow process. Performing an erase each timea sector of data is written is impractical. Writes would be slow andpower consumption inefficient because an entire block, 128 Kbytes, wouldhave to be erased just to write one sector, 512 bytes. To allow rapidsector writes, solid state disk controller 64 writes each sector of datato a new, free location each time a sector is written. A result of thiswrite method is that there may be several versions of the sector dataassociated with a single sector number. The most recent version of thesector data is referred to as a "good sector," "valid sector" or a "usersector." In contrast, the earlier version of the sector is invalid andwill be marked as "dirty."

The actual amount of FLASH memory within FLASH array 62 cannot greatlyexceed the amount stated as available to the user because FLASH memoryis relatively expensive. Stated another way, when the amount of reservememory within FLASH array 62 is lean dirty sectors must be convertedinto free memory to ensure the availability of memory for writes.

FIG. 2 illustrates in block diagram form FLASH array 62 and solid statedisk controller 64. In one embodiment, FLASH array 62 uses thirty 1megabyte, by 8, FLASH memory chips. These FLASH memories include a writestate machine for automatically controlling erasure and programming.These thirty FLASH memory devices function, without data compression, asa 30 megabyte memory disk. Each FLASH chip inputs and outputs data 8bits at a time. To permit word-wide input and output, FLASH array 62 isorganized as pairs of FLASH devices, only one chip pair 66 of which isshown. High chip 68 of chip pair 66 stores the high byte of a word,while low chip 70 stores the lower byte of a word. Solid state diskcontroller 64 is thus able to treat each chip pair as a single 16bit-wide memory device. Word-wide input and output gives solid statedisk 60 a speed advantage compared to magnetic drives, which use serialbit stream I/O.

Each chip pair is organized as 16 blocks, each block including 128Kbytes of memory. Because each block of memory can store many sectors ofdata, each block includes a block sector translation table (BSTT) toidentify and locate each sector of data.

FIG. 3 illustrates block 80 and the file structure used by it and allother blocks. Block 80 is represented as a single word wide structurebut is actually stored in two FLASH chips. The high byte of each word isstored in high chip 68 and the low byte of each word is stored in lowchip 70.

The data structure of block 80 includes block sector translation table84 and data space 86. Block sector translation table 84 stores headers.A header is a block of information about one logical sector number andits associated data. As used herein a logical sector number (LSN) refersto a sector number stored within a BSTT. A sector number is a sectoridentifier received from CPU 52, which the CPU believes corresponds to afixed physical location. However, as a result of the write policy usedby solid state disk 60, an LSN does not correspond to a fixed physicallocation. Also as a result of the write policy used, several headers andLSNs may correspond to a single sector number.

In one embodiment, each logical sector number is 24 bits long.

A header is created for each and every sector number during diskformatting. This allows the loss of sectors of data to be detectedduring the execution of read and write commands. Failure to find theheader associated with a particular sector number indicates that theassociated sector of data has been lost. As used herein "lost" refers toa sector of data that disappears because of a defect in FLASH array 62or to a sector of data that is unreliable because it has been corrupted.

Each header 85 includes a cyclical redundancy check (CRC), which allowssolid state disk 60 to determine the reliability of header 85.

Header 85 also includes an attribute word that contains a great deal ofinformation about the sector data associated with the header. One bit ofthe attribute word indicates whether the sector number has been markedas part of a bad track. Another bit indicates whether or not the sectordata has been compressed. The attribute word includes two dirty bits forreliability. The sector data associated with the header is consideredvalid if both dirty bits are set and dirty if either dirty bit is reset.The attribute word also includes a data attached bit. When no sectordata is attached to the header, the data attached bit is reset. This isthe case for all headers after formatting. Once data is written for thesector number, the data attached bit is set. The final piece ofinformation included in the attribute word is a revision number. Therevision number allows solid state controller 64 to identify the validheader when multiple valid headers with the same LSN exist.

The last piece of information stored in header 85 is a block sectoroffset (BSO). The BSO is an offset from the top of the block to thestart of FLASH memory space associated with the header. Memory space isallocated to a header whether or not data is stored in that space. Ifdata is not attached to the header, then the amount of memory allocatedis the size of data space 86 divided by the maximum number of headers inBSTT 84.

Memory space must be allocated to headers that do not have sector dataattached. This is because during formatting entire BSTTs 84 are filledwith headers that have no data attached. Even though all of data space86 associated with these BSTTs 84 is free, data space 86 cannot bewritten to. There is simply no room in the BSTTs of these blocks. Toavoid a Catch 22 situation in which free memory is not available forallocation, all of data space 86 associated with these BSTTs 84 iscategorized as user data. In other words, the sector is neither dirty,as indicated by dirty bits, nor free. By allocating memory data space 86to headers with unattached data and by subtracting that amount of memoryfrom the amount of free memory in the appropriate block, appropriatechip pair, and array, part of data space 86 is designated as user data.As sectors of data are written after formatting, the headers withoutattached data will be marked dirty, along with their allocated dataspace. Eventually, blocks filled up during formatting will be cleaned-upand their data space made available as free memory.

Because data for one sector is butted up against data for another sectorin data space 86, each BSO indicates the top of data for one sector andthe bottom of data for another sector. For example, the block offset forsector 1, BSO₁, points to the start of the data associated with LSN₁.BSO₁ also points to the bottom of data associated with LSN₂. Another wayof looking at block sector translation table 84 is that each LSN issandwiched between two block sector offsets, one pointing to the top ofthe sector data and the other pointing to the bottom of the sector data.The bottom of the data associated with the sector stored at the bottomof the block, LSN₁, need not be indicated by a BSO as the location ofthe bottom of the block is known.

Block sector translation table 84 grows down toward data space 86. Thefirst header BSTT 84 is written at the top of block 80. The header foreach succeeding sector written into block 80 is stored below theprevious header.

In contrast to BSTT 84, data space 86 grows upward. The first sector ofdata written into block 80 is written into the bottom of data space 86.The next sector of data written into data space 86 is writtenimmediately above the previous sector. For example, the data associatedwith LSN₂ is located within a lower range of addresses than the dataassociated with LSN₁.

The number of sectors that may be stored in data space 86 before it runsinto BSTT 84 varies. This variability arises from data compression,which causes sector size to vary. With data compression, sector size mayvary between 256 words to just a few words. A maximum of 2047 sectorsmay be stored in data space 86 given the seek strategy used by solidstate disk 60.

Solid state disk controller 64 prevents BSTT 84 and data space 86 fromcrashing into each other as they grow. In fact, solid state diskcontroller 64 ensures that some slack 88 is maintained between BSTT 84and data space 86. Slack 88 is free FLASH memory, which has not beenprogrammed. According to the conventions of FLASH memory, a free memorylocation stores FFFF (hexadecimal). During seeks of block sectortranslation table 84, slack 88 indicates that the end of BSTT 84 hasbeen reached.

Block 80 also stores block attribute data 90. Information specific tothe block is stored as block attribute data 90. For example, blockattribute data 90 includes cycle count, which indicates the number oftimes the block has been erased and written to. Block attribute data 90may also include block defect information.

B. Overview of the Solid State Controller Hardware

Referring once again to FIG. 2, reading, writing, and clean-up of FLASHarray 62 is controlled by solid state disk controller 64. Microprocessor92 manages these tasks using database 93, sector header translationtable (SHTT) 94 and the algorithms of the present invention, which arestored in FLASH memory 95. Databases 93, SHTT 94, and algorithms will bedescribed in greater detail below.

An application specific integrated circuit (ASIC), window ASIC 96,serves as a window to the outside world for microprocessor 92 as well aswindows into the FLASH array 62. Via window ASIC 96, microprocessor 92receives commands from CPU 52 and reads and writes to FLASH array 62.Window ASIC 96 includes four windows, allowing microprocessor 92 torepeatedly and rapidly access a number of FLASH memory locations. Thus,window ASIC 96 increases the addressable memory space of microprocessor92. Data to and from CPU 52 flows through window ASIC 96 to sectorbuffer 98.

ASIC 96 also includes data compressor 97. Data compressor 97 receivesuncompressed sectors of data from host CPU 52, compresses the sectors,and passes them to sector buffer 98. Analogously, data compressor 97receives compressed sectors of data from sector buffer 98, decompressesthe compressed sectors, and couples uncompressed sectors of user data tohost CPU 52.

The use of data compressor 97 is not intended solely to increase thestorage capacity of solid state disk 60. The maximum number of sectorsof user data that can be stored within solid state 60 is fixed bycontroller at a number of sectors that is less than the number ofsectors possible given the physical capacity of FLASH array 62 and theaverage rate of data compression of data compressor 97. Setting themaximum number of sectors to a number less than possible given theaverage compression of data compressor 97 means that the reserve memoryand the storage capacity of solid state disk 60 can both be increasedsimultaneously. To illustrate, assume that FLASH array 62 has thecapacity to store 30 MBytes, or approximately 62,475 sectors, withoutdata compression. Further, assume data compressor 97 has an averagecompression ratio of 1.59. Thus, an uncompressed sector of 512 byteswill be reduced to 322 bytes, on average, by data compressor 97. This isan average savings in memory space of 189 bytes per sector. This savingscan be allocated between host 52 and reserve memory in any arbitrarymanner chosen. So long as some part of the average savings realized fromcompression is allocated to reserve memory then clean-up efficiency andpower efficiency will be improved by data compression.

Savings due to data compression are allocated to host 52 by increasingthe maximum number of valid sector numbers beyond that of the physicalcapacity of FLASH array 62. For example, suppose it is desired toallocate 50% of the average savings, or 94 bytes maximum per sector, tohost 52. This means that any compression return, i.e. savings, greaterthan 94 bytes will be used as FLASH memory reserves. Achieving a savingsof 94 bytes/sector is equivalent to an effective compression rate withrespect to the host of 1.18, or ##EQU1##

An effective compression rate of 1.18 allows host 52 to write a maximum73,721 sectors in a 30 Mbyte drive. In this case, whenever thecompression ratio for a sector of data exceeds 1.18 then reserve memorywill be increased. The amount of the increased reserve memory is thedifference between the uncompressed sector and the sum of the compressedsector size and the bytes/sector allocated to the host. Assume as beforethat 94 bytes/sector are maximum allocated to the host. Assume furtherthat for a particular sector the compression ratio is 1.59. This meansthe sum of the compressed sector size and the bytes allocated to thehost is 322+94, or 416 bytes. The savings allocated to reserve memoryfor this sector is 95 bytes, or 512 bytes-416 bytes. Stated in equationform:

    Increase in Reserve Memory=Uncompressed sector size-(Compressed Sector size+Maximum Numbers of Bytes Allocated to Host)

Note there is no limit, beyond the maximum compressibility of the sectoron the number of bytes by which reserve memory may be increased.

Note also that using compression does not necessarily mean that reservememory will be increased. There are circumstances, which thoughunlikely, in which compression decreases reserve memory. A decrease inreserve memory may occur whenever some portion of the increased capacitydue to compression is allocated to the host, and the data beingcompressed is unusual or the actual compression ratio is less than theeffective compression ratio chosen. Data is unusual if compression doesnot reduce its size. These sectors are said to "explode".

A failure of compression to increase reserve memory is not catastrophicto clean-up, however. As will be described in detail, a warning systemprotects the minimum memory reserves required for clean-up byprohibiting host writes until the host releases data space. Thus, acompression ratio less than the effective compression ratio means thathost 52 is allowed to write fewer sectors of data than controller 64originally indicated.

In summary, it will be understood that on average compression increasesreserve memory. Given that the actual compression ratio varies for eachsector, the number of bytes by which reserve memory is increased willvary. For some sectors, reserve memory may be increased and for othersreserve memory may be decreased.

How does increased reserve memory increase clean-up efficiency and powerefficiency of solid state disk 60? As will be explained in detail below,clean-up is triggered when the amount of dirty memory within solid statedisk 60 exceeds a selected percentage of reserve memory. By increasingthe amount of reserve memory data, data compressor 97 increases theamount of dirty sectors required to trigger clean-up. The block selectedas the focus block during clean-up is thus dirtier than it would beotherwise. The increase in the number of dirty sectors within the focusblock decreases the number of clean sectors that must be copied out ofthe focus block prior to its erasure. Further, compression reduces theaverage size of a sector. Thus, the time and energy required to clean-upa focus block is reduced as compared to when reserve memory is notincreased by data compression.

Data compressors are well known in the art, thus, data compressor 97will not be described in detail herein.

Returning now to a more general discussion of FIG. 2, sector buffer 98allows data transfers to CPU 52 to occur more rapidly than possibleotherwise. Solid state disk controller 64 includes charge pump 100.Charge pump 100 converts 5 volts into the 12-volt level needed forprogramming and erasure. Charge pump 100 is not necessary unless thevoltage levels supplied to solid state disk 60 are all below the 12-voltvoltage level necessary to program the FLASH devices within FLASH array62.

C. FLASH Array Database and Sector Header Translation Table

Performance of solid state disk 60 is enhanced by storing repeatedlyused information in random access memory (RAM). This information isreferred to as FLASH array database 93 because it generally relates tocurrent characteristics of FLASH array 62. Information within FLASHarray database 93 includes:

1. The total number of dirty Words within FLASH array 62 (TDFA);

2. The total number of dirty words in each block (TDFB_(N));

3. The total number of free words within FLASH array 62 (TFFA);

4. The number of free words within each chip pair (TFFC_(M)); and

5. The total number of free words within each block (TFFB_(N)).

The use of FLASH array database 93 by solid state disk controller 64will be described below on an algorithm by algorithm basis.

Sector header translation table (SHTT) 94 translates a sector numberinto a pointer to an associated sector of data. To permit its frequentand easy modification, SHTT 94 is preferably stored in RAM. The pointersupplied by sector header translation table 94 does not point directlyto the data associated with the given sector number. Rather, the pointersupplied by SHTT 94 points to a location within BSTT 84 near the headerassociated with the sector number.

The reason why SHTT 94 does not point directly to the header associatedwith the sector number can be understood by examining the number of bitsnecessary to uniquely address each possible header in a BSTT 84. Amaximum of 2047 headers may be stored in a BSTT 84. Given 15 chip pairs,each including 16 blocks in a chip pair, FLASH array 62 could store asmany as 491,280 headers. Uniquely identifying that many headers requires19 bits. Storing 19 bits requires using three by 8 RAM chips. Thus, 5 of8 bits in one RAM would be wasted to store three bits. This is anexpensive and unacceptable solution in the effort to produce a pricecompetitive solid state memory disk.

A number of SHTT designs solve this 19 bit dilemma. One embodiment,shown in FIG. 4, stores a pointer for every valid sector number. Thenumber of valid sector numbers depends upon the memory capacity of FLASHarray 62 indicated by controller 64 to host 52. Only 16 bits are storedfor each entry in SHTT 94. Four of the bits indicate the chip pair inwhich the sector data being sought is stored. Another four bits indicatethe particular block in which the sector is stored. The remaining 8 bitsrepresent an offset from the top of the block to a header which is nearthe desired header. This offset is called a header pointer. Using 8 bitsto represent the header pointer means that there are 256 header pointersavailable to locate a maximum of 2047 headers. Consequently, a maximumof 8 headers must be scanned in BSTT 84 to locate the desired header.Stated another way, SHTT 94 requires a two tiered search to locate thesector of data associated with a particular sector number. First, SHTT94 is searched to locate a particular chip, block and header pointer.Second, the indicated area of BSTT 84 is searched to find the headerassociated with the sector number.

SHTT 94 of FIG. 4 stores a physical address for each sector of datastored on solid state disk 60. The number of entries in SHTT 94 can bereduced by using a most recently used cache memory.

Both FLASH array database 93 and SHTT 94 must be generated duringpower-up because they are stored in volatile memory, RAM, and becausereads and writes depend upon 93 and 94. FIG. 5 illustrates an algorithmto build both FLASH array database 93 and SHTT 94. Using this algorithmboth SHTT 94 and the FLASH array database 93 are generated by scanningeach BSTT 84. The location of the header associated with each sectornumber is noted, as well as the amount of free and dirty memory withinthe block.

Building begins in step 110 with the initialization of SHTT 94. Eachpointer for each sector number is set to the same initial value. In oneembodiment, that value is FFFF (hexadecimal). As a result, afterbuilding SHTT 94 retrieving a pointer equal to the initial valueindicates that the sector of data associated with the sector number hasbeen lost because during formatting a header is created for each sectornumber. Microprocessor 92 branches from step 110 to step 111.

In step 111 total amount of free memory within FLASH array, TFFA, andthe total amount of free memory per chip, TFFC_(M), are initialized totheir maximum values. The maximum free FLASH per chip is 64Kbyte/block * 16 blocks, or 2048 Kbyte per chip pair minus the blockattribute data stored in each block. Similarly, TFFA_(max) is 2048 Kbyteper chip pair * 15 chip pairs, or approximately 30 Mbyte. This done,microprocessor 92 branches to step 112 to begin scanning BSTTs 84.

In step 112 microprocessor 92 determines whether any block within FLASHarray 62 remains to be scanned. If so, microprocessor 92 proceeds tostep 114 and selects a block to scan, B_(C). From step 114,microprocessor 92 branches to step 115. There the total amount of freememory in the current block, TFFB_(C), is initialized to its maximum.Microprocessor 92 then proceeds to step 116.

In step 116, microprocessor 92 reads the next header from the selectedblock's block sector translation table 84. Afterward, microprocessor 92branches to step 118.

Microprocessor 92 begins to classify the current header in step 118.Microprocessor 92 determines whether the header has been marked dirty byreading the dirty bits included in the attribute word of the currentheader. If either dirty bit is a logical zero, the data associated withthe LSN is considered dirty. If the sector of data is dirtymicroprocessor 92 branches to step 120 to update FLASH array database93.

In step 120, microprocessor 92 determines the size of the dirty sectorof data, which may vary as a result of data compression. Sector size isdetermined by comparing the block sector offsets on either side of thecurrent LSN. After determining the size of the dirty sector,microprocessor 92 updates TDFA and TDFB_(C). The total number of dirtywords, TDFA, and the total number of dirty words within the currentblock, TDFB_(C), are increased by the size of the sector and its header.Afterward, microprocessor 92 advances to step 121.

Microprocessor 92 appropriately revises its FLASH free variables. Thesize of the current sector and its header are subtracted from TFFA,TFFB_(C) and TFFC_(C). Afterward, microprocessor returns to the buildingof FLASH array database 93 and SHTT 94 by branching back to step 116.

On the other hand, if the sector is not dirty microprocessor 92 branchesfrom step 118 to step 122. Microprocessor 92 then examines the attributeword within the current header to determine if the end of the BSTT 84has been reached. If the attribute word for the next header is FFFF(hexadecimal), the end has been reached. In this case, microprocessor 92branches back to step 112 to determine whether scanning of BSTTs 84should continue. In all other cases, microprocessor 92 advances to step124 from step 122.

Entry into step 124 means that the current header is associated with avalid sector of user data. Accordingly, microprocessor 92 reduces freevariables TFFA, TFFB_(C) and TFFC_(C) by the size of the current sector.(The subscript "C" designates "current.") This done, microprocessor 92advances to step 126.

In step 126, revision of the SHTT entry for the current header begins byseeking an entry in SHTT 94 for the sector number equal to the LSNincluded in the current header. If the current entry in the SHTT is FFFF(hexadecimal), no information exists for the sector number.Microprocessor 92 responds to this situation by branching to step 128.Any entry other than FFFF for the sector number means that there are twovalid versions of the data for that sector number. To sort things out,microprocessor 92 advances to step 130.

Consider first the simpler situation; that is, when no data is stored inSHTT 94 for the sector number corresponding to the current LSN. In step128, microprocessor 92 writes the chip, block and header pointer for thecurrent header into SHTT 94. This done, microprocessor 92 branches backto step 116 to examine another header.

Things are more complicated when SHTT 94 already includes an entry forthe sector number associated with the current LSN. In step 130, themicroprocessor determines which header and thus which sector of data ismost current by comparing their revision numbers. In step 132,microprocessor 92 then marks dirty the earlier, invalid, sector of databy programming the dirty bits in its header to a logical 0.

In step 133, the microprocessor updates database 93 to reflect the totalnumber of dirty words for the block including the sector just markeddirty and the total number of dirty words for FLASH array 62. The updateis accomplished by adding the sector size to TDFB_(C) and TDFA.

SHTT 94 is finally updated, if necessary, in step 134. No update isnecessary if the header and LSN selected in step 116 were marked dirtyin step 132. Otherwise, the chip pair, block and header pointer for theLSN selected in step 116 are written into SHTT 94.

From step 134, microprocessor 92 returns to step 116. There anotherheader is selected.

After every header within FLASH array 62 has been scanned, building ofSHTT 94 is complete. If a header has not been located which correspondsto a sector number, the pointer within SHTT 94 remains at its initialvalue. Thus, the pointer indicates that the sector of data has been lostand every sector of data is accounted for by SHTT 94.

II. Solid State Disk Controller

The heart of solid state disk controller 64 is the firmware storedwithin FLASH memory 95. This firmware controls the reading, writing, andcleaning-up of FLASH array 62. The firmware also helps create theillusion that CPU 52 is dealing with an industry-standard hard magneticdisk drive.

The object diagram of FIG. 6 illustrates the general organization andinterrelationship of firmware used by solid state controller 64. Thefirmware of solid state disk controller 64 is organized into threeclasses: top level scheduler 150, host interface 152, and FLASH media154. Top level scheduler 150 handles the allocation of microprocessor 92processing time between the other two classes 152 and 154. Hostinterface 152 interprets industry standard disk drive commands from CPU52 and translates them into commands that FLASH media 154 can act upon.FLASH media 154 interfaces directly with FLASH array 62, responding toread and write requests from host interface 152. FLASH media 154 alsomanages the cleaning-up of FLASH array 62.

The scheduling of host interface 152 and FLASH media 154 is a relativelysimple task. Power-up of solid state disk 60 fires top level scheduler150. It initializes the solid state disk 60 and then calls hostinterface 152. This allocates to CPU 52 all the resources of solid statedisk 60. When host interface 152 returns control to top level scheduler150, clean-up object 164 is called. If a clean-up is on-going, then aslice of microprocessor 92 execution time, 500 μseconds in oneembodiment, is allocated for clean-up. When clean-up returns control totop level scheduler 150, host interface 152 is called again. Top levelscheduler 150 repeats the process again and again for as long as solidstate disk 60 is powered up.

Host interface 152 includes two classes of algorithms, interface 156 andsector buffer 158. Interface 156 emulates an AT-IDE hard disk interface.Interface 156 handles ATA command interrupts and translates ATA commandsinto commands comprehensible by FLASH media 154. In alternateembodiments, host interface 156 may simulate a SCSI disk interface orother standard disk drive interface. Sector buffer 158 manages the usageof sector buffer 98.

Briefly described, FLASH media 154 includes five types of firmware, orservices: disk 160, sectors 162, clean-up 164, FLASH power 166 and FLASHarray interface 167. Disk 160 services read and write requests frominterface 156. Disk 160 also translates other commands from interface156 and delegates them for execution to fellow classes 162, 164, 166 and167. Sectors 162 is responsible for most tasks relating to sectorsstored within FLASH array 62. Sectors 162 maintains FLASH array database93 used by both disk 160 and clean-up 164, as well as allocating freememory space within FLASH array 62. Sectors 162 also controls thereading of data from FLASH array 62 via FLASH array interface 167 andsequencer 168. FLASH power 166 is essentially a device driver; that is,it generates the voltage levels necessary to read or write to FLASHarray 62. FLASH array interface 167 handles the low level routines whichdirectly control the reading and writing of FLASH array 62. Sequencer168 handles the movement of data between sector buffer 98 and FLASHarray 62. Just as its name implies, clean-up 164 manages the clean-up ofFLASH array 62. FLASH power 166 manages the limited current budget ofsolid state disk 60, which in one embodiment is only 120 mA.

Given that erasing a block in a chip pair requires up to 60 mA efficientmanagement of current is a concern. Using data compression while onlypermitting host CPU 52 to write a number of sectors that is less thanthe maximum possible given the average compression ratio of datacompressor 97 increases the power efficiency of solid state disk 60. Forexample, assume that the average compression ratio of data compressor 97is 1.59. Thus, the maximum number of sectors that the host could writein a 30 MByte array using data compressor 97 is 1.59×62,475 sectors, or99,335 sectors. If host 52 is allowed write less than 99,335 sectorswhile data compression is used, then reserve memory within solid statedisk 60 may be increased. This, in turn, improves the power efficiency,and clean-up efficiency of solid state disk 60.

How does the increase in reserve memory improve power efficiency? Aswill be explained in detail herein, clean-up is triggered when aselected percentage of reserve memory is dirty. Increasing reservememory increases the actual amount of reserve memory that must be dirtybefore clean-up is triggered. That is to say, increased reserve memoryallows solid state disk 60 to get dirtier before clean-up is triggered.As solid state disk 60 is dirtier, the focus block selected for clean-upis dirtier. Thus, the number of clean sectors of data that must becopied out of the focus block is reduced. Further, the size of the cleansectors are reduced. As a consequence the total amount of energyrequired during clean-up of a focus block is reduced.

A. Reading a Sector from FLASH Array 62

Briefly described, reading a sector is a three step process. First, SHTT94 is searched for a pointer to the header associated with the sectornumber. Second, the header is located and its attribute word is examinedto see if the attached data is valid. Third, if the sector dataassociated with header is valid, its location is determined and returnedto CPU 52.

A read service implemented by disk 160 is illustrated in the flowdiagram of FIG. 7. All callers input a sector number.

The first task of microprocessor 92 in step 170 is examination of theinput sector number for validity. The maximum number of sectors selectedby solid state disk controller 64 determines whether a sector number isvalid.

Microprocessor 92 branches from step 170 to step 172 if the callingservice passed in an invalid sector number. Microprocessor 92 indicatesthe invalidity of the sector number to the caller by setting a statusword to invalid sector number range. Microprocessor 92 then branches tostep 174, returning control to the caller.

On the other hand, microprocessor 92 proceeds to step 176 from step 170if the caller has requested to read a sector with a valid sector number.In step 176, microprocessor 92 takes the sector number and searches SHTT94 for the chip, block and header pointer associated with the sectornumber.

Microprocessor 92 determines in step 178 whether data exists for thesector number requested. Microprocessor 92 may be able to tell whether aheader exists for a particular sector number by examining the headerpointer retrieved from SHTT 94. If the header pointer is FFFF(hexadecimal), a valid header cannot be found for the sector number,even though a header is created for every sector number duringformatting.

Microprocessor 92 responds to a lost sector by branching to step 180from step 178. There microprocessor 92 indicates that the header was notfound. Microprocessor 92 then branches to step 174, the read complete.

On the other hand, if a header exists for the sector number thenmicroprocessor 92 branches to step 182. There sectors 162 seeks for theheader associated with the input sector number. If the desired header islocated, sectors 162 indicates the chip pair, block, and offset to thatheader. Sectors 162 also indicates if the desired header cannot befound.

Once sectors 162 returns from its seek, microprocessor 92 branches tostep 184 to determine the success of the seek. If the seek service didnot locate the header associated with the sector number, microprocessor92 branches to step 180 to so inform the caller. On the other hand, ifthe appropriate header was located microprocessor 92 branches to step186. There the information retrieved in step 182 is passed to the readservice of sectors object 162. The data associated with the sectornumber will be copied into sector buffer 98 and provided to host CPU 52.Afterward, the read complete, microprocessor 92 returns control to thecaller by branching to step 174.

FIG. 8 illustrates a method of seeking sector data given a sectornumber. This service also is implemented by sectors 162.

Briefly described, the seek service of FIG. 8 has two approaches tolocate the data associated a sector number. The first approach reliesupon data coherency to decrease seek time. That is, it is assumed thatthe sector of data being currently sought is related to, and locatednear, the last sector of data located. If this approach fails to locatethe desired sector of data, then a two tiered approach is used. First,SHTT 94 is searched to locate a chip, block and a header offset for thesector number input, SN_(i). Then, using that information, a BSTT 84 issearched for a header with an LSN equal to the sector number input bythe caller.

Location of the sector of data begins in step 190. There microprocessor92 determines whether another header is stored in the last BSTT 84searched. If so, it is possible that the header associated with theinput sector number resides within the same BSTT 84. In that case,microprocessor 92 advances to step 192. However, if the last headerlocated was the last header located within its BSTT 84, then it is notpossible to quickly locate the sector of data associated with the inputsector number. A two tiered search must be used. Microprocessor 92advances to step 206 in that case to begin that two tiered search.

Consider first, the actions of microprocessor 92 upon entry to step 192.Microprocessor 92 reads the header immediately following the last headerlocated. Let us designate the LSN in this header "LSN_(L+1)." LSN_(L+1)is compared to SN_(i) in step 194 to determine if the current header isthe desired header. If LSN_(L+1) does not equal SN_(i) then the sectorof data must be located another way. In that case, microprocessor 92advances to step 206. On the other hand if LSN_(L+i) does equal SN_(i)then microprocessor 92 branches to step 196.

With step 196 the process of determining the reliability of the currentheader begins. During step 196 microprocessor 92 generates a cyclicalredundancy check (CRC) for the current header. Let us call this CRC"CRC_(G)." In step 198 CRC_(G) is compared to the CRC stored in theheader itself, CRC_(stored). The information within the current headeris considered reliable when CRC_(G) =CRC_(stored). Microprocessor 92responds to this condition by branching to step 200. On the other hand,if the current header is not reliable because CRC_(G) does not equalCRC_(stored) then microprocessor 92 proceeds to step 206.

Consider first the actions of microprocessor 92 when the desired headerhas been located. Microprocessor 92 first determines the size of thesector of data associated with the header in step 200. This is doneusing the appropriate block sector offsets, as previously discussed. Thesector size, chip pair, block and offset to the desired header arereturned to the caller in step 202.

When it is successful, the method of steps 190-202 reduces the timerequired to locate a sector of data by a factor of four as compared tothe two-tiered search of steps 206-222.

The two-tiered search begins with step 206 after the quicker approachhas failed. Microprocessor 92 performs the first level of search byseeking SHTT 94 for the chip pair, block and header pointer associatedwith the sector number input SN_(i). The values for the chip pair, blockand header pointer retrieved in step 206 are examined in step 208 todetermine whether a header can possibly be located for SN_(i). If thevalues are equal to the initial value, then the header associated withSN_(i) has been lost. In one embodiment the initial, invalid values areFFFF (hexadecimal). Microprocessor 92 responds to invalid chip pair,block and header pointer values by branching to step 224. There thecaller is informed that the header associated with the input sectornumber was not found. On the other hand, if the values retrieved fromSHTT 94 are valid, microprocessor 92 advances to step 210.

The second tier of the seek begins in step 210 by initializing a scancount to zero. The scan count tracks the number of headers examinedduring the seek. Microprocessor 92 then reads the header near the headerpointer.

From step 210, microprocessor 92 advances to step 212 to compare thecurrent scan count to the maximum scan count.

The maximum number of headers that must be scanned is set by dividingthe maximum number of headers in a BSTT 84 by the maximum number ofheader pointers. For example, in one embodiment of solid state disk 60,a maximum of 2047 headers are stored in BSTT 84 and only 256 headerpointers are used. Thus, a maximum of 8 headers must be scanned in thisembodiment. If the scan count is less than the maximum, microprocessor92 branches to step 214 to continue the search for the desired header.On the other hand, once the scan count equals the maximum microprocessor92 advances to step 224 from 212.

Consider first the situation when the scan count is less than themaximum. Microprocessor 92 enters step 214 where it compares the LSNstored in the current header to the input sector number. If the two areequal the desired header may have been located. In step 214,microprocessor 92 determines whether the current header is the onesought by comparing the sector number input, SN_(i), to the LSN storedin the block. If LSN=SN_(i), microprocessor 92 advances to step 216.Otherwise, the search for the desired sector must continue.

The search of the desired sector continues in step 222 by incrementingthe scan counter and reading another header located beneath the lastheader. Microprocessor 92 then returns to step 212 to determine whetherthis new header is the desired header.

When an LSN is equal to the input sector number, microprocessor 92advances to step 216 from step 214. In step 216 a cyclical redundancycheck, CRC_(G), is generated for the current header. CRC_(G) is used instep 218 to assess the reliability of the information included in theheader.

In step 218 reliability of the header is determined by comparing CRC_(G)to the CRC stored in the selected header. The information within theheader cannot be relied upon unless the two CRCs are equal.

Microprocessor 92 branches to step 220 from step 218 if the currentheader is not reliable. Because the block sector offset within thecurrent header cannot be relied upon, two sectors of data are lost. Forexample, assume that the header being scanned was the header for LSN₁,illustrated in FIG. 3. Because BSO₁ cannot be relied upon, neither thestart of data for LSN₁, nor the end of data for LSN₂ can be determined.Thus, in step 220 microprocessor 92 discards two sectors of data bymarking dirty both the selected header and the header immediatelybeneath it. Microprocessor 92 then advances to step 222.

If the current header can be relied upon, microprocessor 92 advances tostep 200 from 218. Having reached step 200, microprocessor 92 beginsgathering the information needed to read the sector data. First, thesize of the sector is determined by reading the appropriate BSOs.Finally, in step 202 the sector size and attribute word is returned tothe caller along with the chip pair, block and offset to the header.Microprocessor 92 then returns control to the caller in step 204.

B. Writing a Sector to FLASH Array 62

Writing a sector of data involves three major tasks. First, enough freememory to write the sector data must be located and reserved. Second,any previous version of sector data with the same LSN is marked dirtyand SHTT 94 is updated. Third, the sector data and its header arewritten into the appropriate block.

FIG. 9 presents an overview of the process of writing a sector of datainto FLASH array 62. A write begins when disk 160 receives a writecommand accompanied by an input sector number, SN_(i), from CPU 52. Atthis point, the data to be written into FLASH array 62 resides withinsector buffer 98 and is already compressed if data compression is beingused. A number of outcomes are possible using the service of FIG. 9depending upon the LSN_(i) and the data stored in SHTT 94.

Consider first the outcome when SN_(i) is invalid. The first action ofmicroprocessor 92 upon receipt of the write command is to examineSN_(i). This is done in step 230. Any SN_(i) greater than the maximumnumber indicated to host 52 by controller 64 will not be written intosolid state drive 60.

Given that the SN_(i) is invalid, microprocessor 92 branches from step230 to step 232. There microprocessor 92 sets the status word to informinterface 156 that the sector number received was invalid. That done,microprocessor 92 advances to step 234. Control of microprocessor 92then returns to the calling program.

Assume now that SN_(i) is valid, and that its attribute word indicatesthat the track associated with SN_(i) has been marked bad. BecauseSN_(i) is valid, microprocessor 92 branches to step 236 from step 230.

Preparations to write the sector begin in earnest in step 236.Microprocessor 92 enables charge pump 100, enabling it to develop the 12volt level necessary to program the FLASH memory. Microprocessor 92 thenperforms other tasks until charge pump 100 reaches 12 volts.

In step 238, microprocessor 92 calls the seek service to locate the chippair, block and header pointer for an earlier version of the sectordata. After locating the information associated with the sector number,microprocessor 92 branches to step 240.

In step 240, microprocessor 92 determines whether the bad track bit hasbeen set. Microprocessor 92 does so by examining the sector attributeword. Given that the bad track bit has been asserted, microprocessor 92advances to step 242 from step 240.

Microprocessor 92 will not write the sector data into FLASH array 62because the track associated with SN_(i) has been marked bad. In step242, microprocessor 92 informs interface 156 that the track is bad.Afterward, microprocessor 92 returns control to interface 156 bybranching down to step 234.

The previous discussions show that a sector of data will not be writteninto FLASH array 62 if either SN_(i) is invalid or its associated trackhas been marked bad. Stated conversely, sector data will be written intoFLASH array 62 if it is associated with a good track and valid SN_(i).Consider now such a situation. Microprocessor 92 responds by branchingfrom step 240 to step 244.

In step 244, microprocessor 92 continually queries charge pump 100 todetermine whether it has reached 12 volts. The amount of time requiredby charge pump 100 to reach 12 volts cannot be predicted because itvaries depending upon how long it has been since charge pump 100 waslast enabled. The less time that has passed since charge pump 100 wasenabled, the less time required to reach 12 volts again. Once chargepump 100 stabilizes at 12 volts, microprocessor 92 branches to step 246.

In step 246, microprocessor 92 determines whether a previous header withthe same LSN should be marked dirty. Microprocessor 92 makes thisdetermination based upon the information retrieved by the seek of step238. If a header was located, microprocessor 92 proceeds to step 247 tomark that header dirty. Afterward, microprocessor 92 advances to step248 to determine whether the previous header was marked dirty or whetherthe task was cached. If the task was not cached, microprocessor 92advances to 250. Otherwise, microprocessor 92 branches to step 249.Because the mark dirty task was cached, there will be two headers withthe same LSN at the end of the current write. To distinguish the validdata after power-loss, the revision number for the LSN associated withthe most current version is incremented in step 249. Microprocessor 92then proceeds to step 250.

With step 250, microprocessor 92 begins the process of writing the newversion of the sector data within FLASH array 62. Microprocessor 92allocates sufficient free memory within FLASH array 62 to store thesector of data and header. This is an involved process that will bedescribed in detail later. Suffice it to say that allocation of memoryrequires locating sufficient memory within data space 86 of a block andmarking that memory space as reserved. Microprocessor 92 then proceedsto step 252.

Microprocessor 92 completes the writing of the header in steps 252 and254. First, in step 252, a CRC is generated for the header, whichexcludes the dirty bits and revision numbers because they may be changedin the course of events. Afterward, in step 254, the CRC, attribute wordand LSN are written into BSTT 84. The LSN is set equal to SN_(i).

Microprocessor 92 finally writes the sector data into data spacereserved in step 256. An error correction code, ECC, is also writtenwith the data.

Once a compressed sector is written into FLASH array 62, reserve memorymay be increased. Whether reserve memory is increased depends upon themaximum number of sectors host 52 is allowed to write, the compressionratio for the sector just written, and the number of bytes allocated tohost 52 because of compression. Assume as before that the compressionratio for the sector just written was 1.7, i.e. only 302 bytes werewritten. If 94 bytes of the 210 byte savings are allocated to host 52,then reserve memory is increased by 116 bytes, i.e., 512-(302+94).

The new version of the sector data safely written, in step 258microprocessor 92 updates sector header translation table 94 so that itpoints to the most recent version of the sector data associated with thesector number.

In step 260 microprocessor 92 disables charge pump 100. Turning chargepump 100 off when it is not needed reduces power consumption. Thisenhances the suitability of solid state disk 60 for use in portable andlaptop computers. This done, microprocessor 92 branches to step 262.

During step 262, microprocessor 92 forces an evaluation of whetherclean-up is necessary as a result of the write. Microprocessor 92 doesthis by calling a service named "Enable CSM," which will be described indetail later. This done, microprocessor 92 advances to step 234,returning control to the caller.

C. Allocating Memory Space for a Write

Allocating memory space within FLASH array 62 is a complex and criticaltask: Not only must memory space be allocated, an appropriate locationmust be chosen to prevent performance degradation. Choosing a block fora sector write potentially involves four major decisions. First, arethere sufficient FLASH memory reserves to allow the write? Second, isthere enough free memory in the block to which the current process waslast allocated to store the current sector? If the answer to the secondquestion is no, then a third and a fourth question must be asked. Isthere a block with enough free FLASH memory to store the sector data? Isthat block an appropriate block in which to store this sector?

The fourth decision is a difficult one because whether a block is anappropriate block depends on a number of factors. First, the blockchosen cannot be included in a busy chip pair. Waiting on a busy chippair is avoided because it diminishes the speed with which commands fromCPU 52 are obeyed. Second, the block chosen should not be within a blocktargeted for clean-up. Data written into a block targeted for clean-upwill just have to be relocated right away. Third, the block chosenshould not be within the same chip pair allocated to another process.This avoids data fragmentation, which eventually results in foregrounderase and decrease in power efficiency. Data fragmentation refers to arandom distribution throughout FLASH array 62 of dirty memory, freememory, and clean memory, which is also referred to as sectors of userdata. Data fragmentation is catastrophic to solid state disk performancewhen reserves of memory space are lean. By allocating writes initiatedby CPU 52 into different blocks than writes initiated by clean-up, dirtysectors are likely to be grouped together. This reduces the number ofsectors that must be copied out of a block during clean-up, therebyimproving power efficiency and clean-up performance.

FIGS. 10A and 10B are a flow diagram of a service for allocating memorythat may be used for host writes or for clean-up. The service shownbelongs to sectors 162. Given the size of the sector to be written andthe caller type, the allocate service locates and reserves sufficientmemory. The reserved location is stored in RAM for future reference bythe service.

A number of outcomes are possible using the allocation service of FIGS.10A and 10B. Consider first the outcome of greatest interest: memory isallocated. Other outcomes will be considered afterward.

Allocation of memory begins at step 271 by determining whether memoryhas been requested for clean-up or for a host write. If clean-uprequires free physical memory microprocessor 92 branches ahead to step282. On the other hand, when host CPU 52 requests memory microprocessor92 must decide whether to allow the write in view of available memoryreserves. This determination takes place in steps 272 through 280.

Microprocessor 92 begins its determination in step 272 by calculatingwhat the available reserves after writing a sector of the desired sizewould be. As used here, "reserves" refer to both free and dirty memorywithin FLASH array 62 and "sector size" includes both the size of thedata and the header. The available reserves are then compared to a firstwarning level, FLASH Warn 1. In one embodiment, FLASH Warn 1 represents19 blocks of reserves. If the available reserves exceed FLASH Warn 1,microprocessor 92 advances to step 273. There, microprocessor 92indicates that reserve status is acceptable. Afterward, microprocessor92 proceeds to step 282. On the other hand, if available reserves willnot exceed FLASH Warn 1, microprocessor 92 proceeds to examine thereserves in greater detail. First, however, microprocessor 92 signalsthat reserves have fallen below the first warning level by setting thereserve status to FLASH Warn 1 in step 274.

In step 275 the available reserves remaining after the write arecompared to a second warning level, FLASH Warn 2. In one embodiment,FLASH Warn 2 represents 11 blocks of reserve. Microprocessor 92 branchesahead to step 282 if available reserves after the write exceed thissecond warning level. Otherwise, microprocessor 92 proceeds to step 276.There the reserve status is reset to indicate reserves have fallen belowthe second warning level.

Microprocessor 92 reevaluates the available reserves in step 278 bycomparing them to a third warning level, standby. In one embodiment,standby represents 2 blocks of reserves. If available reserves willexceed standby after the write, then microprocessor 92 permits the writeby branching to step 282. Microprocessor 92 advances to step 279 ifavailable reserves will not exceed standby. There the reserve status isset to standby. As a result, no more writes by CPU 52 will be permitteduntil sectors are released by host CPU 52. Control is then returned tothe caller in step 304 as illustrated in FIG. 10B.

With step 282 microprocessor 92 begins searching for a block with enoughfree memory in data space 86 to store the sector data to be written.Microprocessor 92 searches for a block using a set of block chains, twoof which are illustrated in FIG. 11. Block chain 320, figurativelyspeaking, chains together block 1 of each chip pair (CP_(M)) withinsolid state disk 60. Similarly, block chain 322 links together block 15of each chip pair (CP_(M)). Blocks 2 through 14 are linked together insimilar chains, though they are not shown. Chaining blocks together inthe fashion shown is not necessary but causes sectors of data to bedistributed across chip pair boundaries. This provides passivewearleveling and nearly eliminates the need for active wearleveling.

Microprocessor 92 uses block chains in conjunction with pointers storedin RAM. Microprocessor 92 stores the chip and block last allocated toeach caller. The next time the same process attempts to write a sector,the allocation algorithm first examines the last block allocated to thatprocess. This helps keep related data "files" in contiguous memory spaceand helps reduce the possibility of data fragmentation. Asmicroprocessor 92 searches for a block for each caller, the caller'spointer circles around a block chain. The starting pointer stored in RAMfor each caller is different to help avoid data fragmentation. Eachpointer moves around the block chains at its own rate. Additionally,each pointer moves from block chain to block chain at a different rate,depending upon the availability of free memory. No two pointers everpoint to the same block in any chain.

With this understanding of block chains, return once more to adiscussion of the location of a block with enough memory according tothe allocation service of FIGS. 10A and 10B. In step 282 microprocessor92 determines whether every block chain has been examined for availablespace. If even a single block chain has not been examined yet,microprocessor 92 branches down to step 284 from step 282.

In step 284 microprocessor 92 determines whether every chip in thecurrent block chain has been searched for available space. If not, achip is selected from the current block chain. The first chip chosen onthe block chain is the last chip allocated into by the same process.Thus, if CPU 52 last wrote a sector into CP3, block 5, then the firstblock examined for the next write will be CP3, block 5. A block selectedmicroprocessor 92 branches to step 286.

In step 286, microprocessor 92 queries the status register of thecurrent chip pair to see if the chip pair is busy. If that chip is busythen microprocessor 92 branches to step 288.

In step 288 microprocessor 92 selects the next chip on the current blockchain. For example, if chip pair 3, block 5 was selected in step 284then chip pair 4, block 5 will be selected. This done microprocessor 92branches back up to step 284.

In step 284, microprocessor 92 again checks to see if every block on thecurrent block chain has been searched. As this is the second block onthe chain to be examined, microprocessor 92 advances again to step 286.

Here microprocessor 92 determines whether the current chip pair is busy.If so, microprocessor 92 will branch through steps 288 and 284 as justdescribed. On the other hand, if the current chip pair is not busymicroprocessor 92 proceeds to step 289 of FIG. 10B.

Microprocessor 92 determines whether the currently selected chip pair isallocated to another caller. Microprocessor 92 does this in step 289 bycomparing chip pairs and blocks stored in RAM for other callers to thecurrently selected chip pair and block. For example, let us assume thatthe caller is CPU 52 and that chip pair 4, block 4 is allocated to it.If a block in chip pair 4 is allocated to clean-up state machine 1, thenmicroprocessor 92 will not allocate memory space within chip pair 4 toCPU 52. In this situation, microprocessor 92 proceeds to step 290 ofFIG. 10B.

Another block on the current block chain is selected in step 290. Fromstep 292 microprocessor 92 branches back up to step 284.

As we have assumed that earlier that memory will be allocated,microprocessor 92 will eventually reach step 291 by branching throughsteps 284, 286, and 289. In step 291, microprocessor 92 determineswhether the current block selection is part of a chip that has anotherblock targeted for clean-up. If so, the current block selection isundesirable unless erasure can be suspended to program. Otherwise,writing the sector would be delayed by erasure. To avoid this,microprocessor 92 selects another chip in the current block chain instep 292. The appropriateness of that block is then determined bybranching through steps 284-291 again.

Microprocessor 92 reaches step 293 when a block that is not involved inclean-up is located. Here microprocessor 92 determines whether anotherheader can be written into BSTT 84 of the current block consistent withthe seek scheme. For example, in one embodiment only 2047 headers may bewritten into any BSTT given a maximum examination of eight headers perseek and the use of only 256 header pointers. If the maximum number ofheaders has already been written into BSTT 84, another block must beselected. Microprocessor 92 does so, by branching to step 294.Otherwise, microprocessor 92 continues its evaluation of the currentblock by branching to step 295.

In step 295 microprocessor 92 determines whether there is enough freememory within data space 86 of the current block to store the sector.This check is necessary because compression causes sector size to vary.As a result, the number of sectors of user data that can be stored indata space 86 varies. Microprocessor 92 must select another block ifdata space 86 does not include sufficient memory to store the sector tobe written. Microprocessor 92 does so in step 296.

Once a block with sufficient room to store the sector is located,microprocessor 92 performs one last check before allocating the sectordata into the current block. In step 297, microprocessor 92 examines theblock's block attribute data 90 to determine if the block is good. If itis not, microprocessor 92 advances to step 298 to select another chip onthe current block chain. On the other hand, if the block is good, anappropriate block has finally been found. Microprocessor 92 responds bybranching to step 299.

In step 299, for future reference microprocessor 92 stores in RAM, thechip pair and block just selected.

By branching to step 300, microprocessor 92 finally allocates memory forthe sector to be written. Microprocessor 92 does this by writing theblock sector offset into BSTT 84 of the selected block.

Microprocessor 92 updates FLASH array database 93 in step 301. The totalamount of free memory within FLASH array 62, the chip and the block(TFFA, TFFC(C_(M)) and TFFB(B_(N))) are decreased by size of the sector.When the database update is complete, microprocessor 92 branches to step302.

Finally, in step 302 the chip pair, block and offset to the header arereturned to the caller. As used herein, "offset to the header" or"header offset" refers to the offset from the top of the block to thetop of the header. Allocation complete, control returns to the caller instep 304.

There are a number of situations under which memory space cannot beallocated using the service of FIGS. 10A and 10B. Perhaps memory cannotbe allocated because solid state disk 60 is in standby mode or becausean appropriate block cannot be located. However, and wherever, thedecision is made that memory cannot be allocated, microprocessor 92 endsup in step 306.

Referring to FIG. 10A, in step 306, microprocessor 92 determines whetherits inability to allocate memory can be remedied. That depends upon thecaller that requested memory space. If the caller is CPU 52,microprocessor 92 advances to step 308. On the other hand,microprocessor branches to step 310 if the caller requesting memoryspace is one of the two clean-up state machines.

If the caller is CPU 52, the inability to allocate memory can beremedied by foreground clean-up. Accordingly, in step 308,microprocessor 92 initiates a foreground clean-up. As a result, CPU 52will have to wait a relatively long time before any of its writecommands are obeyed.

Very little need be done if memory cannot be allocated and the caller isone of the clean-up state machines. As will be described in detaillater, foreground clean-up uses more than one clean-up state machine. Inone embodiment, foreground clean-up uses two clean-up state machines.The first clean-up state machine runs uninterrupted until it beginserasing a block. At that time, the second clean-up state machine isstarted. It may not be possible, however, to allocate memory to thesecond clean-up state machine because so many blocks are unavailablebecause of erasure by the first clean-up state machine. This is notcatastrophic because completion of clean-up by the first clean-up statemachine will produce large amounts of free memory. Microprocessor 92prepares to await that event in step 310 by changing to idle, the statusof the calling clean-up state machine. Microprocessor 92 then returnscontrol to the caller in step 304.

FIGS. 12A and 12B illustrate in flow diagram form an alternate method ofallocating free physical memory for host writes. Like the method ofFIGS. 10A and 10B, choosing a block to allocate the write into mayinvolve up to four decisions. Two of the decisions for allocating memoryare made in essentially the same manner as they are made according tothe method of FIGS. 10A and 10B. Those decisions are:

1. Is there enough reserve memory to permit the write?

2. Is this block an appropriate block to allocate the write into?

The method of FIGS. 12A and 12B increases data coherency for host writesby choosing a new block to allocate host write which has the largestamount of free memory rather than choosing the first block with enoughmemory to store the sector of data to be written, as done with themethod of FIGS. 10A and 10B. As a result of choosing the block with thegreatest amount of free memory, larger amounts of host data residewithin the same block because writes are allocated into the chosen blockuntil there is insufficient free memory to store another sector of data.This method of allocation increases data coherency.

Allocation of free physical memory begins in step 1202 by determiningwhether minimum memory reserves within flash array 62 would bemaintained after writing the sector requested. If not, host CPU 52 isinformed that solid state disk 60 is in FLASH STANDBY in step 1204. Nofurther host writes will be permitted until host microprocessor 92releases sufficient memory to reach minimum memory reserves. On theother hand, if minimum memory reserves are available, microprocessor 92proceeds to step 1205.

To increase data coherency and decrease the possibility of datafragmentation, in step 1205 microprocessor 92 attempts to allocate thesector into the block host data was last written into. For simplicity'ssake, let us refer to this block as "the previous block." Microprocessor92 first determines which block is the previous block and ascertains theamount of free memory remaining in the previous block by referring todatabase 93. If the amount of free memory in the previous block is equalto or greater than the sector size, the sector will be written into theprevious block. In that case, microprocessor 92 branches ahead to step1262 to reserve memory in the previous block. On the other hand, ifthere is insufficient free memory in the previous block, microprocessor92 branches to step 1206.

In steps 1206, 1208, and 1210 microprocessor 92 initializes variablesused in the selection of a block. During these steps Most Free Block,Most Free Chip, and Greatest Score are initialized to zero. Most Freerepresents the amount of free flash memory in the Most Free Block.Afterward, microprocessor 92 advances to step 1212.

Step 1212 begins a block by block evaluation of each block in FLASHarray 62. Each block is first examined to determine its appropriatenessin steps 1214-1230. Once a block is found to be appropriate, thedesirability of allocating the sector write into that block isdetermined by generating a score for the block in steps 1232-1240. TheTotal score for each block is then compared to Greatest Score. If thatTotal score exceeds Greatest Score, then Most Free, Most Free Block,Most Free Chip, and Greatest Score are all revised to reflect the valuesof the current block in steps 1243-1248.

Choosing a block begins in step 1212 by determining whether all blockshave been examined, and thus, whether a block has been selected forallocation. Microprocessor 92 does this by determining whether all chippairs have been searched. The first pass through step 1212,microprocessor 92 selects a block for examination and branches to step1214 because not a single chip pair has been examined.

In step 1214, microprocessor 92 queries the status register of thecurrent chip pair to see if the chip pair is busy. If that chip pair isbusy, it will be unavailable for a relatively long period of time. Forthis reason, microprocessor 92 branches to step 1212 to select anotherblock when the current block is part of a busy chip pair. Otherwise,microprocessor 92 advances to step 1216.

In step 1216, microprocessor 92 determines whether the current block ispart of a chip pair that includes another block targeted for clean-up.If so, the current block selection is undesirable unless erasure can besuspended to program. Otherwise, writing the sector could be delayed byerasure. To avoid this, microprocessor 92 returns to step 1212 toselects another block. When a current block is selected that is notincluded in a chip pair targeted for clean-up, microprocessor 92advances to step 1218.

During step 1218 microprocessor 92 determines whether memory in thecurrently selected block chip pair has been recently allocated to aclean-up state machine. Such a block is an inappropriate choice for ahost write because it increases the possibility of data fragmentation.Microprocessor 92 makes this decision by comparing chip pair and blockstored in RAM for the clean-up state machine to the currently selectedchip pair and block. For example, let us assume that the current blockselection is chip pair 4, block 4. If a block in chip pair 4 isallocated to clean-up state machine 1, then microprocessor 92 will notallocate memory space within chip pair 4 to CPU 52. In these situations,microprocessor 92 returns to step 1212 to select another block.

In step 1220 microprocessor 92 examines the block attribute data 90 forthe current block to determine if the block is good. If it is not,microprocessor 92 advances to step 1212 to select another block. On theother hand, if the block is good, microprocessor 92 responds bycontinuing its evaluation of the appropriateness of the current block.

Step 1230 is the final step in determining whether the current block isan appropriate block is assessing whether space remains in the BSTT 84of the current block. If the maximum number of headers has already beenwritten into BSTT 84, another block must be selected.

Exiting step 1230 to step 1232 of FIG. 12B means that the current blockis appropriate for allocation for host writes. Thus, microprocessor 92begins evaluating the desirability of the current block, as reflected bya total score encompassing a number of factors. The first factorconsidered is the total number of free words within the current block,TFFB_(C). TFFB_(C) is multiplied by a first weight (W1) to generate Rule1, the value of which should be substantially larger than the value ofother weights. This skews the selection of a block toward the block withthe greatest amount of free physical memory.

Microprocessor 92 continues evaluation of the desirability by branchingto step 1234. Microprocessor 92 examines the likelihood that the currentblock will be impacted by a future clean-up by subtracting the amount ofdirty memory within the current chip pair, designated TDFC, from thetotal possible amount of dirty memory with the current chip pair, TPDFC.The remainder of this operation is then multiplied by weight 2 (W2) togenerate Rule 2. The smaller TDFC, the larger Rule 2 and the less likelyit is the current chip pair will soon be selected for clean-up.

The desirability of the current block is also evaluated in terms of theamount of dirty memory within the current block, TDFB. In step 1235,TDFB is multiplied by weight 3 (W3) to generate Rule 3.

Another factor evaluated in assessing the desirability of the currentblock is the number cycle counts of the current block compared to themaximum cycle count within array 62. This factor, represented by "deltacycle count" is multiplied by weight 4 (W4) in step 1236 to generateRule 4. This factor skews selection of a block toward blocks with lowercycle counts and results in passive wear leveling.

Microprocessor assesses the fifth and final factor of the currentblock's desirability in step 1238. That factor is whether any otherblock in the current chip has not been allocated into. This alsoprovides some wear leveling by spreading sector data across chipboundaries. This factor is multiplied by weight 5 (W5) to generate Rule5.

Microprocessor 92 generates a total score for the current block in step1240 by adding together Rule 1, Rule 2, Rule 3, Rule 4, and Rule 5.Microprocessor 92 then compares this total to the Greatest Score. If thetotal exceeds the Greatest Score then the current block is the mostdesirable block of the blocks that have been evaluated so far. Thus, insteps 1243, 1244, 1246, and 1248, Greatest Score, Most Free, Most FreeBlock and Most Free Chip are revised to reflect the values of thecurrent block. Afterward, microprocessor 92 returns to step 1212 toevaluate another block in FLASH array 62.

After all blocks have been evaluated, microprocessor 92 branches to step1250. There it is determined whether there is sufficient free memory inthe most free block to store the sector of data that CPU 52 wants towrite. If there is, allocation proceeds by branching to step 1262.Otherwise, microprocessor 92 branches to step 1260.

Entry to step 1260 means that FLASH array 62 must be cleaned-up before ablock with sufficient free memory to store the current sector can belocated. Thus, microprocessor 92 initiates foreground clean-up. Once ablock has been cleaned-up, microprocessor 92 returns to step 1212 toselect another block for allocation.

Eventually, a block with enough space to store the sector of data willbe identified and microprocessor 92 will reach step 1262. Allocation ofmemory space for the sector of data begins in earnest by identifying thenext available header in the BSTT 84 of the Most Free Block. Theappropriate block sector offset for the sector is then written into thatheader in step 1264. Afterward, the total amount of free flash in thearray, in the Most Free Chip and the Most Free Block are decreased bythe size of the sector. Finally, in step 1266 microprocessor 92indicates the chip pair, block and offset to the header now associatedwith the sector of data to be written.

D. Marking Dirty a Version of a Sector

FIG. 13 illustrates in flow diagram form a service for marking a sectordirty, which is implemented by sectors 162. This service is usefulduring writes, clean-up, and creation of sector header translation table94.

The mark dirty service requires three pieces of information: the chippair, block, and offset to the header for the sector data to be markeddirty. Given this information, the first task of microprocessor 92 instep 320 is to determine the availability of the chip pair storing thatversion of the sector data. Therefore, in step 320, microprocessor 92reads the status register associated with the appropriate chip pair. Ifthe chip pair is busy microprocessor 92 branches to step 322. On theother hand, if the chip pair is not busy, microprocessor 92 branches tostep 324.

Entry into step 322 means that the desired sector is unavailable.Clean-up is the sole possible explanation for unavailability of the chippair. Rather than waiting for clean-up to finish, microprocessor 92figuratively leaves itself a note to mark the previous copy of thesector dirty. Microprocessor 92 does this by caching the chip pair,block, and offset to the header of the sector data to be marked dirty.When clean-up is complete, the cache will be checked and the sectormarked dirty. Afterward, microprocessor 92 branches to step 326 toreturn control to its caller.

Microprocessor 92 proceeds to step 324 from step 320 if the chip pairstoring the previous copy of the sector data is not busy. Theremicroprocessor 92 marks dirty the copy of the sector pointed to by chippair, block and offset. The sector of data is marked dirty by setting to0, dirty bits in the attribute word of the sector's header. This done,microprocessor 92 proceeds to step 326, returning control to the caller.

III. Clean-up of the Solid State Disk

Solid state disk drive 60 achieves write speeds close to conventionalmagnetic disk drives by writing a sector of data to a new location eachtime it is revised, rather than erasing the previous location andwriting the revised data to that same physical location. As a result ofthis practice, solid state disk 60 becomes sprinkled with dirty sectors.Recovering the memory space occupied by dirty sectors mandates clean-up.Stated slightly differently, the write practices of solid state diskcontroller 64 require that dirty sectors be converted into free memory.

Briefly described, clean-up involves three major tasks. First, a blockis selected as the focus of clean-up. Second, sectors of valid user dataare copied from the focus block into other blocks, referred to asdestination blocks. Third, after all valid sectors have been copied outof it, the focus block is erased, converting dirty sectors into freememory.

The efficiency of clean-up is improved through the use of datacompressor 97 while allowing a maximum number of sectors of data to bewritten to solid state disk 60 that is less than possible given theaverage compression ratio of data compressor 97. For example, if theaverage compression ratio of data compressor 97 is 1.59 and the physicalcapacity of FLASH array 62 is 62,475 uncompressed sectors then a maximumof 99,335 compressed sectors could be written. So long as controller 64permits fewer than 99,335 sectors to be written, then reserve memory maybe increased. (Recall from the previous discussion that compression can,in certain circumstances, decrease reserve memory) Increased reservememory increases clean-up efficiency because compression allows solidstate disk 60 to become dirtier before clean-up is triggered. Becauseblocks are dirtier before clean-up is triggered fewer sectors of userdata must be copied out of the focus block, and these sectors aresmaller. The result is less time and energy is required to clean-up afocus block. Further, the return for clean-up is increased; i.e., thenumber of dirty bytes converted to free memory is increased.

Clean-up is a background process, generally. Clean-up is able to run asa background process because reads and writes to FLASH array 62generally occur in bursts. As a result, there are relatively longperiods of time when microprocessor 92 is free to perform clean-up.

Clean-up is managed by a finite state machine, called a clean-up statemachine (CSM). That is, clean-up is achieved using a finite number ofstates, or algorithms, which are chained together. Each clean-up statepoints to the next state, in effect chaining each state to anotherstate. Each state takes no more than 500 μseconds of microprocessor 92time to execute.

Background clean-up uses a single clean-up state machine, and is grantedexecution time only when host interface 152 is inactive. In contrast,two clean-up state machines run simultaneously during foregroundclean-up of solid state disk 60. Clean-up becomes a foreground task whenwrite commands from CPU 52 cannot be executed because of lack of freememory for write requests.

Background and foreground clean-up are both handled by clean-up object164 of solid state disk controller 64. FIG. 14 illustrates in blockdiagram form the high level services of clean-up object 164. Algorithmsinclude enable CSM 340, force clean-up 342, force multicleanup 344,execute one state 346, and multiCSM execute until condition 348.

Background clean-up is initiated when enable CSM service 340 is called.Enable CSM 340 is called whenever the host writes to solid state memorydisk 60. For example, enable CSM 340 is called in step 262 of the writeservice of FIG. 9. Enable CSM 340 activates a clean-up state machine bysetting a CSM next state pointer to a clean-up state.

Execution of that first clean-up state occurs whenever top levelscheduler 150 allocates microprocessor 92 time to clean-up. Top levelscheduler 150 does so by calling execute one state algorithm 346.Execute one state 346 calls the state pointed to by the CSM next statepointer. That state, whichever it is, modifies the next state pointerprior to surrendering control of microprocessor 92. Thus, each time toplevel scheduler 150 allocates execution time to clean-up another stepwill be executed by calling execute one state.

Foreground clean-up begins by calling service 348 of clean-up 164.MultiCSM execute until condition 348 is called when no free memory canbe allocated for a write request. This represents a decision that freememory needs to be generated before anymore writes will be executed.MultiCSM execute until condition 348 does this by enabling two clean-upstate machines.

In contrast to foreground and background clean-up, both ForceCleanUp 342and ForceMultiCleanup 344 are called by CPU 52. Force clean-up 342enables one clean-up state machine, while ForceMultiCleanup 344 enablestwo clean-up state machines.

A. Backaround Clean-up

1. Initiating Background Clean-Up and the Linking of Clean-up States

Background clean-up is initiated by a call to enable CSM 340. A flowdiagram for enable CSM 340 is shown in FIG. 15.

The first task of microprocessor 92 in step 360 is to determine whetherclean-up state machine 1 is already active. If so, nothing is to bedone. In that case, microprocessor 92 branches to step 361 without doinganything. If clean-up state machine 1 is not active microprocessor 92branches to step 362.

In step 362, microprocessor 92 performs the first of the two small tasksnecessary to begin background clean-up. There microprocessor 92 bringsclean-up state machine 1 (CSM1) active by setting a variable,CSM1.status, to active. This done, microprocessor 92 proceeds to step364.

Next, microprocessor 92 performs the second task required to set-upbackground clean-up. This is done by setting CSM1 next state pointer toEvaluate If Cleanup Is Needed state 380. The next time top levelscheduler 150 calls execute one state 346 background clean-up willbegin. Its job done, microprocessor 92 branches to step 361.

FIG. 16 is a flow diagram of execute one state 346, the service thatchains the states of a clean-up state machine together. The mechanismthat allows a single service to chain many states together is the CSMnext state pointer. Each clean-up state machine has its own next statepointer, which is updated at the end of each state.

Upon entry to execute one state 346, microprocessor 92 determineswhether the second clean-up state machine, CSM2, is active by examiningCSM2.status. If CSM2 is not active, microprocessor 92 branches directlyto step 370. On the other hand, CSM2 may be active as a result of aforeground clean-up that is just finishing-up. In this case,microprocessor 92 executes another state of CSM2 in step 368. Control isthen returned to the caller in step 374.

Once CSM2 is idle, microprocessor 92 will devote its attention to CSM1if CSM1 is active. Microprocessor 92 makes this determination in step370. If CSM1 is inactive, nothing is to be done but to return control tothe caller in step 374. Otherwise, the state pointed to by the CSM1 nextstate pointer is executed. Afterward, control is returned to the callerin step 374.

2. Overview of the States of a Clean-up State Machine

What is the chain of events during clean-up? Briefly described, clean-upinvolves three major tasks regardless of the type of clean-up. First, ablock is selected as the focus of clean-up. Second, on a goodsector-by-good sector basis, user data is relocated from the focus blockinto destination blocks. Relocation of user data is itself a multistepprocess, requiring allocation of memory, copying of the sector into thedestination blocks, and updating of FLASH database 93. Third, after alluser data has been copied out of it, the focus block is erased,converting dirty sectors into free memory.

FIG. 17 gives an overview of clean-up by illustrating each state of aclean-up state machine. Each bubble in FIG. 17 represents one state, orservice, of a clean-up state machine. The arrows between statesrepresent the next state pointed to by the CSM next state pointer at theend of a state.

Background clean-up begins in state 380 by evaluating whether clean-upis necessary. Evaluation of whether clean-up is necessary is skippedduring foreground clean-up and forced clean-up. If clean-up is notnecessary microprocessor 92 branches down to state 396. This returnscontrol of microprocessor 92 to top level scheduler 150. On the otherhand, if clean-up is deemed necessary, a number of blocks will becleaned up. The selected number of blocks is indicated by a counter.Afterward, microprocessor 92 is pointed to state 382 by the CSM nextstate pointer.

Clean-up begins in earnest in state 382 by selecting a focus block toclean-up. The next state pointer then points microprocessor 92 to state383.

Prior to cleaning up dirty sectors within the focus block, valid sectorsof user data must be safely relocated. This task requires branchingthrough states 383, 384, 385, 386, and 388 repeatedly until each andevery sector of user data within the focus block has been safely copiedinto new locations. Relocation of user data begins in state 384 bylocating a new physical location for one good sector of user data. Theblock selected as the new location is referred to as a destinationblock. According to this terminology, clean-up has one focus block butmay have many destination blocks.

Data compressor 97 reduces the number of sectors of use data that mustbe copied out of focus block, as well as reducing the size of thesectors when the maximum number of sectors of user data allowed to bewritten by host CPU 52 does not equal the average compression rate ofdata compressor 97 multiplied by the maximum number of uncompressedsectors that can be stored within FLASH array 62. This is in contrast tothe situation when data compression is not used. Reducing the number ofsectors of user data to be copied from the focus block also reduces thetotal time required to clean-up the focus block, which improves clean-upperformance, power efficiency and solid state disk performance. Afterstate 384, microprocessor 92 is then pointed to state 385 by the CSMnext state pointer.

In state 385, the sector is copied from the focus block into sectorbuffer 98.

In state 386 microprocessor 92 copies part of a valid sector from thesector buffer to the current destination block. Only a part of the validsector is copied at one time given write speeds and the desire to keepbackground clean-up from impacting response to read and write commandsfrom CPU 52. Thus, microprocessor 92 may pass though state 386 severaltimes before a valid sector is completely copied into a destinationblock. Once the valid sector has been completely copied, the CSM nextstate pointer directs microprocessor 92 to state 388.

During state 388 microprocessor 92 updates sector header translationtable 94 so that it points to the new location of the sector just copiedfrom the focus block if the previous version of the data for the sectornumber was not marked dirty. Otherwise, microprocessor 92 marks dirtythe version of the sector it has just copied. Finally, microprocessor 92finishes writing the header associated with the new version of thesector data for the sector number. Microprocessor 92 then returns tostate 383.

Upon reentry to state 383, microprocessor 92 determines whether everygood sector within the focus block has been relocated. If not, anothergood sector will be selected for relocation, and microprocessor 92 willbranch through states 384, 385, 386, 388 and 383 until every good sectorwithin the focus block has been relocated. When that occurs, the CSMnext state pointer directs microprocessor 92 to state 390.

Microprocessor 92 begins erasure of the focus block in state 390.Microprocessor 92 initiates erasure by giving an erase command to thechip pair and indicating the block to be erased. This done,microprocessor 92 proceeds to state 392 to wait for the completion oferasure. The CSM remains in state 392 until the chip pair including thefocus block indicates completion of erasure.

The focus block erased, microprocessor 92 updates and copies blockattribute data 90 back into the focus block. This done microprocessor 92is redirected to state 380 by the CSM next state pointer.

Upon reentry to state 380, microprocessor 92 examines the block counterto determine if another focus block should be selected. If so,microprocessor 92 will branch through states 382, 384, 386, 388, 390,392, and 394 as described. Otherwise, microprocessor 92 branches to step396, clean-up complete.

3. Evaluating if Clean-up is Necessary

FIG. 18 illustrates in flow diagram form the service used in state 380to evaluate whether FLASH array 62 should be cleaned-up. Using thisservice, background clean-up is triggered when total dirty memory risesabove a set percentage of total memory reserves. Total memory reservesare defined as the sum of total free memory (TFFA) and total dirtymemory (TDFA). The percentage of total dirty to total reserves affectsthe performance and power efficiency of solid state disk 60.

Microprocessor 92 begins in step 400 by determining whether evaluationis necessary. This is done by examining a counter to determine thenumber of blocks remaining to clean-up. Any number greater than zeroindicates that clean-up has already been triggered and furtherevaluation is not necessary. The first time microprocessor 92 entersstate 380 the counter will be less than zero, forcing microprocessor 92to branch to step 402.

In step 402 microprocessor 92 calculates the total amount of dirtymemory within FLASH array 62 as a percentage of total memory reserves.

In step 404 the percentage calculated in step 402 is compared to aclean-up trigger point. The clean-up trigger point may be fixed at acertain percentage of total memory reserves or it may be adaptivelyvaried based upon the demands of CPU 52. A service for adaptivelyvarying the clean-up trigger point will be described in detail later. Ifthe total dirty is equal to, or exceeds, the trigger pointmicroprocessor 92 sets background clean-up in motion by branching tostep 406. On the other hand, if the percentage of total dirty memorydoes not exceed the trigger point microprocessor 92 branches to step409. Because clean-up is not necessary, the status of CSM1 is set toidle. Control is returned to top level scheduler 150 without initiatingclean-up by branching to state 410.

Microprocessor 92 sets the block counter in step 406 to the maximumnumber of blocks to be cleaned-up. In one embodiment, that maximum isset to three. This done, microprocessor 92 advances to step 408.

In step 408, microprocessor 92 advances the CSM next state pointer tothe next state in the clean-up process, state 382. This done,microprocessor 92 returns control to top level scheduler 150 bybranching to step 410.

During subsequent calls to evaluate if clean-up is necessary, state 380microprocessor 92 begins by examining the block counter in step 400. Ifthe block counter exceeds zero the need for clean-up will not beevaluated. Instead, microprocessor 92 decrements the block counter andbranches to step 401.

In step 401 microprocessor 92 points the CSM next state pointer to state382, choose block to clean up. Microprocessor 92 then exits state 380via return step 410.

FIG. 19 illustrates in flow diagram form a service for adaptivelyvarying the trigger point used in step 404 to evaluate whether clean-upis necessary. The service shown belongs to sectors 162.

In step 412, microprocessor 92 determines whether the trigger point hasbeen set too low; that is, whether FLASH array 62 is being allowed toget too dirty: Microprocessor 92 does this by determining whether somenumber of foreground clean-ups have occurred in the last M writes, whereM is a large number. If so, microprocessor 92 advances to step 414.Otherwise, microprocessor 92 branches to step 416.

In step 414 microprocessor 92 decreases the trigger point by a smallamount, because FLASH array 62 has been allowed to get too dirty. Theeffect of this is to keep FLASH army 62 from becoming as dirty in thefuture. From step 414 microprocessor 92 returns control to the callingprogram.

In step 416, microprocessor 92 considers whether FLASH array 62 is beingkept too clean. Microprocessor 92 determines this by evaluating thenumber of foreground erases in the last N writes, where N is a largenumber. If there has not been a foreground erase in a very long timemicroprocessor 92 branches to step 418. Otherwise, microprocessor 92proceeds to step 420 without changing the trigger point.

Microprocessor 92 increases the trigger point slightly in step 418. Thisallows FLASH array 62 to become slightly dirtier before backgroundclean-up is triggered, which improves clean-up efficiency. The triggerpoint adjusted, microprocessor 92 returns control to the calling programby branching to step 420.

4. Choosing a Block to Clean-up

Once clean-up is triggered, a focus block is chosen in state 382. Thegoal in choosing a focus block is to select the block that it is mostcost effective to clean. Cost effective clean-up involves striking abalance between keeping FLASH array 62 so clean that power consumptionis excessive and keeping FLASH array 62 so dirty that foregroundclean-up frequently occurs. A number of factors are to be considered indetermining whether a block is a cost effective focus for clean-up.First, how dirty is the block? The dirtier a block is the morecost-effective it is to erase that block. In selecting a focus, thisfactor is weighted heaviest to skew the decision toward minimizingforeground clean-ups. Second, how much free memory is in the chip pairthat the focus is part of? This factor is considered only for FLASHmemory devices without the ability to suspend erasure to program. InFLASH devices without the ability to suspend erasure, every block withinthe chip pair is unavailable during the erasure of a single block. Thisreduces the desirability of cleaning up a particular block if lots offree memory resides within the same chip pair. Third, how much validuser data, or good data, is there within the focus block? This alsoreduces the desirability of choosing a particular block as focus becauseit increases the number of sectors that must be copied out. Statedconversely, the fewer good sectors that must copied out the moredesirable a block is to clean-up. Other factors may be considered whenchoosing a focus block.

FIG. 20 illustrates a service for choosing a block to clean-up in state382 which uses the factors discussed above. Briefly described, a blockis chosen as a focus of clean-up by generating a score for each blockwithin FLASH array 62. The score is generated by appropriately weightingeach of the factors and summing the weighted factors together. The blockwith the highest total score is selected as the focus of clean-up.

Choosing a focus block begins in step 440 by determining whether allblocks have been examined, and thus, whether a focus block has beenselected. Microprocessor 92 does this by determining whether all chippairs have been searched. The first pass through step 440,microprocessor 92 branches to step 444 because not a single chip pairhas been examined.

In step 444 microprocessor 92 selects a block to examine within theselected chip pair. Microprocessor 92 then advances to step 445 if everyblock has not been examined yet.

In step 445, microprocessor 92 determines whether the block is part of achip pair that is currently the focus of clean-up by another clean-upstate machine. This makes the current block a less desirable focus blockbecause all blocks within a chip targeted for clean-up will beunavailable at some point for a long period of time. Microprocessor 92is able to determine whether a chip is targeted for clean-up by anotherclean-up state machine by examining the chip and block informationstored in RAM. After multiplying this factor by weight 0 to generateRule 0, microprocessor 92 then advances to step 446. The Rule 1 score isgenerated by multiplying the total number of dirty words within thecurrent block TDFB_(C), by a first weight (WEIGHT 1). The value of thisweight should be substantially larger than the value of subsequentweights. Microprocessor 92 then branches to step 448 from step 446.

Microprocessor 92 calculates a Rule 2 score for the current block instep 448. There the total amount of free FLASH within the selected chippair TFFC_(C) is multiplied by a second weight (WEIGHT 2). Afterward,microprocessor 92 branches to step 449.

A Rule 3 score is calculated in step 449. The desirability of a block isevaluated there in terms of whether the current block resides within thechip pair last erased. Afterward, microprocessor 92 advances to step450.

In step 450 microprocessor 92 calculates a Rule 4 score for the currentblock. Microprocessor 92 begins calculating this score by subtractingthe total number of good bytes in the current block from the totalnumber of bytes within that block. Microprocessor 92 then multipliesthis number by a fourth weight (WEIGHT 4). The fourth weight is meant tobias slightly the selection of a focus block towards choosing a blockwith less good sector data. Thus, microprocessor 92 then branches tostep 451. The fourth weight is relatively small compared to the firstweight.

The Rule 5 score for the current block is generated during step 451. Thefifth factor considered skews selection toward blocks with lower cyclecounts, thus, performing passive wear leveling. The fewer cycle countsof the current block compared to the maximum cycle count within array62, the more desirable the block is. This factor, represented by "Δcycle count" is then multiplied by the fifth weight (WEIGHT 5).

In step 452 microprocessor 92 generates a total score for the block byadding together Rules 1, 4, and 5, which reflect desirablecharacteristics of the current block. From this sum Rules 0, 2, and 3are subtracted because they indicate undesirable characteristics of afocus block.

Advancing to step 454, microprocessor 92 then compares the total scorefor the current block to the greatest total score. If the total scorefor the current block exceeds the greatest total score, then thegreatest total score is revised upward and microprocessor 92 advances tostep to 456. On the other hand, microprocessor 92 branches back up tostep 444 if the total score for the current block is not greater thanthe greatest total score.

In step 456 microprocessor 92 stores the chip pair, and block and scoreof the block with the current greatest total score. Microprocessor 92then returns to step 444.

Upon reentry to step 444 microprocessor decides whether every blockwithin the currently selected chip pair has been evaluated. If not,microprocessor 92 branches through steps 445, 446, 448, 449, 450, 451,452, 454, 456, and 444 until every block within the selected chip pairhas been evaluated. Microprocessor 92 branches back to step 440 onceevery block within the selected chip pair has been evaluated.

Step 440 determines whether the blocks within every chip pair have beenexamined. If not, microprocessor 92 branches through steps 444, 445,446, 448, 449, 450, 451, 452, 454, 456, and 440 until all blocks in allchip pairs within FLASH array 62 have been evaluated. Microprocessor 92then proceeds to step 458.

Microprocessor 92 writes the chip pair and block selected as the focusof clean-up into the focus window. Microprocessor 92 uses the block andchip address stored in step 456 to do this. Afterward, microprocessorproceeds to step 460.

Having reached its current goal, in step 460 microprocessor 92 sets theCSM next state pointer to allocate free physical sector, state 384.

From step 460 microprocessor 92 returns control to top level scheduler150 by branching to step 462.

5. Allocating Free Physical Sectors for Clean-up

Prior to erasing the focus block, all valid sectors of user data must becopied from the focus block and relocated into destination blocks. Thefirst step in the relocation process is allocating memory space for thesectors of the user data currently residing in the focus block. FIG. 21illustrates a service for state 384, which manages the allocation ofmemory during clean-up.

Microprocessor 92 begins allocation in step 472 by determining whetherevery good sector within the focus block has been relocated.Microprocessor 92 makes its decision by scanning down BSTT 84 of thefocus block until reaching the next header. Every sector of user datahas been copied out of the focus block if the attribute word in theheader is FFFF (hexadecimal). In that case, microprocessor 92 branchesto state 480. If every valid sector has not been copied out,microprocessor 92 examines the attribute word to see if the sector isvalid or dirty. Dirty sectors cause microprocessor 92 to scan down BSTT84 to the next header. Microprocessor 92 responds to good sectors bydetermining the sector size and advancing to step 474.

In step 474 microprocessor 92 allocates memory for the sector identifiedin step 472 by calling the allocate algorithm of FIGS. 10A and 10B or analternate algorithm to be discussed later. Afterward, microprocessor 92advances to step 476.

Microprocessor 92 prepares to exit state 384 in step 476 by resettingthe CSM next state pointer to state 385. Thus, when background clean-upresumes execution, copying of the sector from the focus block intosector buffer 98 will begin. This done, microprocessor 92 returnscontrol to top level scheduler 150 by branching to step 478.

Microprocessor 92 returns again and again to state 476 until every validsector has been copied out of the focus block. Once that occurs,microprocessor 92 branches to step 480 from step 472. In step 480microprocessor 92 initiates focus block erasure by appropriately settingthe CSM next state pointer to start erase. Control is returned to thecalling program.

6. Allocating Free Physical Memory for Clean-up

FIG. 22 illustrates in flow diagram form an alternate method ofallocating free physical memory for clean-up. A block selected as adestination block for clean-up must be both appropriate and desirable.The appropriateness of a block is assessed in essentially the samemanner discussed previously with respect to the allocation methodsillustrated in FIGS 10A, 10B, 12A and 12B. However, the assessment anddefinition of a desirable destination block differs. The most desirabledestination block is the block that most closely fits the sectors ofuser data to be copied out of the focus block. Defining the desirabilityof a destination block in this manner increases the coherency of userdata by preserving large amounts of free data for host writes.

Allocation of memory during clean-up begins with initialization ofvariables used in the selection of the destination block. In steps 2202and 2204 Best Fit Block and Best Fit Chip are both set to 0.

In step 2206 microprocessor 92 calculates the amount of free memorynecessary to store the remaining sectors of user data within the focusblock. Thus, even though memory for only one sector is allocated at atime, desirability is evaluated in terms of a block capable of storingall the remaining sectors of user data within the focus block. (As usedherein, "sectors of user data" and "user data" is defined as memory thatis neither free, nor dirty.)

In step 2207 microprocessor 92 initializes one more variable prior tobeginning its evaluation of possible destination blocks. Score isinitialized to a maximum value representative of the maximum amount offree memory in any block. Score is revised during evaluation to indicatethe score of the most desirable destination block; that is the blockwhose available free memory is closest to the total free memory needed.This done, microprocessor 92 advances to step 2208.

The appropriateness of each block as a destination block is evaluated insteps 2208-2216 in the same manner discussed with respect to FIGS. 12Aand 12B. Therefore, these steps are not discussed in detail.

Eventually an appropriate block will be identified and microprocessor 92will reach step 2218. There the desirability of the current block as adestination block will be determined. One factor defines destinationblock desirability according to the service of FIG. 22. How closely doesthe amount of free memory in the current match the amount of free memoryneeded to store all sectors of user data remaining within the focusblock? A variable, Total, measures the desirability of the current blockin terms of the free memory remaining after storing the user data withinthe focus block. Total may be a positive number or a negative number,depending upon whether the free memory in the current block is too greator too little. Microprocessor 92 then branches to step 2220.

In step 2220 microprocessor 92 determines whether the current block is abetter fit than the block currently selected as the best fit. In otherwords, the absolute value of Total_(CurrentBlock) is compared to theabsolute value of Score. Using absolute values in the comparison ensuresthat blocks that are too small are Considered as well as blocks thathave more free memory than is strictly necessary. Microprocessor 92returns to step 2208 to evaluate another block if the absolute value ofTotal_(CurrentBlock) is not less than the absolute value of Score. Onthe other hand, if the current block is a better fit than a previousblock then microprocessor 92 branches to step 2222 to revise best fitvalues.

Score is reset to Total_(CurrentBIock) in step 2222. Afterward, in steps2224 and 2226 Best Fit Chip and Best Fit Block are revised so that theypoint to the current block. This done, microprocessor 92 returns to step2208 to evaluate another block.

After evaluating each block within FLASH array 62 microprocessor 92exits from step 2208 to step 2238. Microprocessor 92 then determineswhether there is sufficient memory in Best Fit Block to store the sectorof data currently being moved out of the focus block. If not,microprocessor 92 idles the current clean-up machine in step 2230.Otherwise, microprocessor 92 advances to step 2231 to begin the processof actually reserving memory in the Best Fit Block, which it does insteps 2231, 2232, 2234 and 2236 in the same fashion as discussedpreviously with respect to FIGS. 10A, 10B 12A and 12B.

7. Copying Good Sectors

Copying a sector from the focus block into a destination block is a twostep process. The selected sector of valid user data is first copiedfrom the focus block into sector buffer 98. Secondly, the valid sectoris copied from sector buffer 98 into the destination block. This twostep process is not necessary, but it improves the reliability of userdata by taking advantage of the error detection capabilities of an errordetection circuit that is in the path of sequencer 168.

The service of FIG. 23 handles the copying of a sector of user data fromthe focus block to sector buffer 98. First, in step 480, the sector ismoved into sector buffer 98. Second, in step 482, microprocessor 92 setsthe next state pointer to copy part of a sector. Control is thenreturned to the caller in step 484.

Copying a sector from its temporary refuge in sector buffer 98 into thedestination block is the responsibility of state 386, called Copy Partof Sector. Only part of the sector is copied each time state 386 isexecuted to ensure that its execution time is less than a selectedmaximum execution time. In one embodiment the maximum execution time ofeach state is limited to 500 μseconds.

FIG. 24 illustrates a service for copying part of a sector from sectorbuffer 98. Microprocessor 92 begins in step 490 by deciding if the restof the sector can be copied into the destination block within themaximum execution time. In one embodiment, microprocessor 92 does thisby comparing to 20 the number of bytes remaining to be copied fromsector buffer 98. The maximum number of words that can be copied willvary depending upon the selected maximum execution time. Microprocessor92 branches to step 492 if it cannot copy the remainder of the sectorwithin the maximum execution time.

In step 492 microprocessor 92 copies 20 bytes from sector buffer 98 tothe destination block indicated by the clean-up state machine'sdestination window. Afterward, microprocessor 92 branches to step 494.

In step 494 microprocessor 92 points the CSM next state pointer back tostate 386, guaranteeing that all of the sector will eventually be copiedout of sector buffer 98. Control is returned to top level scheduler 150when microprocessor 92 branches to step 500.

Eventually there will be a pass through state 386 in which all remainingwords can be copied into the destination block within the maximumexecution time. During this pass, microprocessor 92 branches from state490 to state 496.

Microprocessor 92 copies all the words remaining in sector buffer 98into the destination block in step 496. Afterward, microprocessor 92advances to step 498.

Having completely relocated the valid sector into its destination block,microprocessor 92 prepares to update sector header translation table 94to reflect the sector's new physical location. At this point,microprocessor 92 also finishes writing the header for the new sector ofdata. This is done in step 498 by resetting the CSM next state pointerto state 388. Copying of the sector finished, microprocessor 92 exitsstate 386 via step 500.

8. Updating Databases After Copying a Sector

Updating of BSTTs 84 and SHTT 94 is delayed until after a sector of userdata has been completely relocated from the focus block to thedestination block. This ensures that CPU 52 always has access to a validcopy of the sector, even while the sector is being relocated. Thus, CPU52 is free to re-write the sector while the sector is being moved. As aresult, there can be three or more versions of the same sector of datawithin FLASH array 62, only one version of which is valid. When thisoccurs, microprocessor 92 has effectively copied a dirty sector duringstate 386. The Post Copy Database Update service of state 388anticipates this problem by determining which databases should beupdated and how they should be updated.

FIG. 25 illustrates a flow diagram for updating databases during state388. Microprocessor 92 begins this task in step 502 by determiningwhether the host has written the sector while the CSM was copying it.Microprocessor 92 can determine this by checking if the header for thesector just relocated has been marked dirty. Let us call thisheader_(FOCUS). Once microprocessor 92 knows this, it knows whichtranslation tables should be updated and how they should be updated.There are two possibilities.

Consider first the train of events when header_(FOCUS) is not markeddirty. In this situation, sector header translation table 94 and blocksector translation tables 84 for both the destination block and focusblock must be updated. To begin to do so microprocessor 92 branches fromstep 502 to step 506.

Database updates begin with the destination block. In step 506,microprocessor 92 writes the LSN into BSTT 84 of the destination block.Afterward, microprocessor 92 branches down to step 508.

Microprocessor 92 changes the address of the sector within SHTT 94 sothat it points to the header in destination block, rather than theheader in the focus block. Microprocessor 92 then advances to step 510.

Microprocessor 92 completes the updating of all three translation tablesin step 510. There microprocessor 92 marks dirty the header in the focusblock. Microprocessor 92 does so by calling the mark dirty algorithm ofFIG. 13. Database updates complete, microprocessor 92 branches to step512.

Entry to step 512 indicates copying of a sector is complete.Microprocessor 92 prepares to scan the focus block for another goodsector to copy in step 512 by setting the CSM next state pointer toallocate free physical sector state 384.

Afterward, control of microprocessor 92 is returned to top levelscheduler 150 by branching to step 514.

What happens if the sector is revised while it is being relocated to thedestination block? As it has already been marked dirty, header_(FOCUS)need not be revised. Nor does SHTT 94 require revision because italready points to the header associated with the revised sector. OnlyBSTT 84 of the destination block requires revision to reflect that theheader in the focus block is invalid. Microprocessor 92 begins this taskby branching from step 502 to step 516.

Microprocessor 92 updates BSTT 84 of the destination block in step 516by calling the mark dirty service of FIG. 13. As before, microprocessor92 returns control to top level scheduler 150 by branching block 514.

9. Erasing the Focus Block

Conversion of dirty sectors into free memory via erasure begins aftercopying all good sectors out of the focus block. Erasure of the focusblock involves initiating erasure and then waiting for erasure tofinish.

FIG. 26 illustrates a service for initiating erasure in state 390. Priorto issuing an erase command, in step 520 microprocessor 92 preservesblock attribute data 90 in step 520 by copying it to sector buffer 98.

At last, in step 522 microprocessor 92 issues the erase command to thechip pair including the focus block. Nothing remains to be done now butto wait.

Microprocessor 92 prepares for its long wait in step 524 by setting theCSM next state pointer to wait for erase complete state 392.Microprocessor 92 then returns control to the calling program bybranching to state 526.

FIG. 27 illustrates a service used to wait for and detect the completionof erasure. In step 530, microprocessor 92 determines whether erasure isstill on-going by querying the chip pair's status register. As long asthe status register indicates that erasure is not complete,microprocessor 92 branches to step 532. There microprocessor 92 preparesto continue its wait by setting the CSM next state pointer to wait forerase complete state 392. Once erasure is complete, microprocessor 92branches to state 534, where the CSM next state pointer is set to posterase update state 394.

10. Posterase Database Update

A few tasks require attention after the focus block has been erased.These tasks are managed by posterase database update state 394, which isillustrated in FIG. 28.

The first task tackled by microprocessor 92 is updating the FLASH arraydatabase to reflect the increased number of cycle counts caused by thepreceding erasure. Microprocessor 92 does this in step 536.

The second task performed by microprocessor 92 is the restoration to thefocus block of its block attribute data 90 with the new cycle count,which was stored in sector buffer 98 during erasure. Microprocessor 92does this in step 538.

Microprocessor 92 performs its last update task in step 540. Theremicroprocessor 92 clears semaphore stored in RAM to indicate that theblock is no longer a focus of clean-up. As a result, the allocateservice of FIG. 11 is free once again to allocate sectors, if possible,into the chip pair including the former focus block.

Before exiting state 394 microprocessor 92 resets the CSM next statepointer to state 380 in step 542, Evaluate If Clean-Up is Necessary.

B. Foreground Clean-up

The goal of foreground clean-up is to generate rapidly a large amount offree memory within FLASH array 62. Foreground clean-up achieves its goalby simultaneously operating two clean-up state machines and forcing CPU52 to wait for free memory. Thus, foreground clean-up differs frombackground clean-up by impacting the computer user. Foreground clean-upalso differs in the manner in which it is triggered as compared tobackground clean-up. When active, background clean-up is initiated aftereach write of a sector by CPU 52. Foreground clean-up is triggeredduring the allocation of free physical memory. If sufficient free FLASHmemory to write a sector cannot be allocated then a call to MultiCSMexecute until condition 348 begins foreground clean-up. Additionally,foreground clean-up differs from background clean-up by foregoingevaluation of whether clean-up is necessary, that decision effectivelybeing made during allocation of free memory. Foreground clean-uptherefore begins by choosing a block to clean-up.

FIG. 29 illustrates the service used to manage foreground clean-up,MultiCSM Execute Until Condition 348. Using this service, the firstclean-up state machine is activated and allowed to run continuouslyuntil it reaches wait for erase complete state 392. At that point, thesecond clean-up state machine is activated and allowed to runcontinuously until it reaches wait for erase complete state 392. Thefirst clean-up state machine then completes the clean-up of its focusblock without interruption. With one block clean, and another block tobe clean shortly, microprocessor 92 again responds to commands from CPU52.

Foreground clean-up begins in step 550 where microprocessor 92 sets toone the block counts for both the first clean-up state machine and thesecond clean-up state machine. Recall from the discussion of FIG. 17that the block count determines how many blocks are cleaned-up, and thushow long clean-up lasts. Setting both block counts to one minimizesforeground clean-up execution time. Microprocessor 92 then advances tostep 552.

With step 552 microprocessor 92 begins the process of activating bothclean-up state machines, which continues through step 562.Microprocessor 92 determines whether the first clean-up state machine,CSM1, is active in step 552 by examining the status of CSM1. If CSM1 isnot active, microprocessor 92 branches to state 554 to activate it. Onthe other hand, if CSM1 is already active, microprocessor 92 branches tostep 558 to activate the second clean-up state machine, CSM2.

Microprocessor 92 changes the status of CSM1 from idle to active in step554. Microprocessor 92 proceeds from step 554 to step 556.

Microprocessor 92 prepares CSM1 to begin clean-up by setting its nextstate pointer to choose block to clean up state 382. This done,microprocessor 92 turns its attention to CSM2 by branching to step 558.

Microprocessor 92-determines whether CSM2, is active in step 558. If so,microprocessor 92 proceeds to step 564 to start running CSM1. Otherwise,microprocessor 92 branches to step 560.

Microprocessor 92 sets CSM2 to its active state in step 560. Afterward,in step 562, microprocessor 92 prepares CSM2 to begin clean-up bysetting its next state pointer to choose block to clean up state 382.

Set-up of the two clean-up state machines complete, microprocessor 92 isfinally able to start one up. In step 564, microprocessor 92 determineswhich clean-up state machine 92 should be given execution time.Microprocessor 92 does this by determining whether CSM1 has begunerasing a block. If CSM1 has not, microprocessor 92 proceeds to step566.

Microprocessor 92 executes one state of CSM1 in step 566. Microprocessorexecutes CSM1 states until wait for erase complete state 392.Microprocessor 92 reaches states 392 by looping repeatedly through steps566 and 564. When CSM1 reaches wait for erase state 392, microprocessor92 turns its attention to more fruitful fields by branching to state568.

Microprocessor 92 determines whether CSM2 requires additional executiontime to finish cleaning its focus block in step 568. If so,microprocessor 92 branches to step 570 where a single state of CSM2 isexecuted. Microprocessor executes CSM2 states until wait for erasecomplete state 392. At this point, microprocessor turns its attentiononce again to CSM1 by branching from step 568 to step 572.

In step 572 it is determined whether CSM1 has completed its clean-up ofits focus block. Microprocessor 92 does this by examining the statusword associated with CSM1. If CSM1 is not idle, microprocessor 92branches to step 574 to execute another CSM1 state. By branching backand forth between steps 572 and 574, microprocessor 92 eventuallycompletes the clean-up managed by CSM1. At this point, one block hasbeen completely cleaned-up and another block will shortly be cleaned-up.With a large reserve of free memory imminent, microprocessor 92 returnscontrol to top level scheduler 150 by branching to step 576. Foregroundclean-up thus ceases.

C. Forced Clean-up

Forced clean-up is yet another way of activating and controllingclean-up state machines. Forced clean-up differs from both foregroundclean-up and background clean-up in that it is initiated by a commandfrom the computer user. In this type of clean-up, the computer userdecides that clean-up is necessary without evaluating the total amountof free memory, as done in state 380.

Solid state disk controller 64 recognizes two types of forced clean-up.One type of forced clean-up activates only one clean-up state machine.This type of clean-up is managed by a service named Force Cleanup 342.The other type of clean-up activates two clean-up state machines and ismanaged by a service called ForceMultiCleanup 344.

FIG. 30 illustrates a service for Force Cleanup 342. The task ofForceCleanup is relatively simple: activate and start-up CSM1, ifnecessary.

In step 580 microprocessor 92 begins its task by examining the status ofCSM1 to see if it is active. If so, microprocessor 92 branches to step587. If CSM1 is idle, then microprocessor 92 branches to step 582.

Microprocessor 92 enables CSM1 in step 582 by changing its status toactive. Microprocessor 92 then forces clean-up to begin by bypassingevaluate if clean-up is necessary state 380 and setting CSM1 next statepointer to choose block to clean-up state 382, step 584. Itsresponsibilities fulfilled, microprocessor 92 branches from step 584 tostep 586.

Microprocessor 92 ensures that CSM1 initiates clean-up in step 587, ifit has not already done so. Microprocessor 92 does so by examiningCSM1's next state pointer and if it is equal to evaluate clean-upnecessary branching to step 584. This circumvents any evaluation thatclean-up is unnecessary.

FIG. 31 illustrates a service for Force Multi Cleanup 344. The task ofthis algorithm is to activate both clean-up state machines, ifnecessary.

The first two steps of Force Multi Cleanup 344 echo the steps of ForceCleanup 342. In step 590, microprocessor 92 determines whether CSM1 isactive. If it is not, in step 592 CSM1 is enabled and choose block tocopy state 382 is selected as the next state of CSM1. On the other hand,if CSM1 is already active, microprocessor 92 branches to step 591.

Microprocessor 92 determines whether CSM1 has begun clean-up in step591. Recall that clean-up of a block is not initiated each time CSM1 isactivated. Clean-up has begun if the next state pointer points to anystate other than Evaluate If Clean-Up is necessary. In this casemicroprocessor 92 branches directly to step 594. Otherwise,microprocessor 92 proceeds to step 592.

There microprocessor 92 forces CSM1 to clean-up a block by resetting theCSM1 next state pointer to Choose Block to Clean-Up. Afterward,attention turns to CSM2 by the branch to step 594 from step 592.

Microprocessor 92 enables the second clean-up state machine, CSM2, instep 594. Microprocessor 92 then bypasses evaluate if clean-up isnecessary state 380 and sets CSM2 next state pointer to choose block tocopy state 382. Microprocessor 92 branches from step 594 to step 596,returning control to top level scheduler 150.

IV. Summary

Thus, a method and apparatus for increasing reserve memory in a solidstate memory disk has been described. The apparatus uses a datacompressor to compress sectors of user data prior to storage. Bycompressing user data without increasing the maximum number of sectorsto that possible given the average compression ratio of the datacompressor, reserve memory within the solid state memory disk isincreased. As a direct result, clean-up efficiency and power efficiencyare improved.

In the foregoing specification, the invention has been described withreference to specific exemplary embodiments thereof. It will, however,be evident that various modifications and changes may be made theretowithout departing from the broader spirit and scope of the invention asset forth in the appended claims. The specification and drawings are,accordingly, to be regarded in an illustrative rather than a restrictivesense.

What is claimed is:
 1. A solid state memory disk for storing a maximumnumber of sectors of data for a host, the solid state memory diskcomprising:a) an array of solid state memory devices which includes freememory and dirty memory, and stores sectors of valid data, the arraybeing capable of storing the maximum number of sectors as uncompressedsectors, each memory device including a first multiplicity of blocks ofmemory; b) a controller for controlling the array, the controllerindicating to the host the maximum number of sectors, the controllerwriting a first compressed sector of valid data to a first location in afirst block in the array in response to a first write command from thehost, the controller writing a second compressed sector of data to asecond location in a second block and marking dirty the first locationin the first block in response to a second write command from the host;c) a clean-up machine for generating free memory by erasing the firstblock after copying all compressed sectors of valid data within thefirst block out of the first block and into another block; and d) acompressor responsive to the controller for compressing sectors of datareceived from the host and coupling compressed sectors of data to thearray, the compressor having an average compression ratio, thecompressor increasing reserve memory when the average compression ratiois greater than one, wherein the reserve memory includes free memory anddirty memory.
 2. The solid state memory disk of claim 1 furthercomprising:e) a decompressor responsive to the controller receivingcompressed sectors of data from the array, decompressing the sector dataand transferring the decompressed data to the host.
 3. A solid statememory disk having reduced energy consumption, the solid state memorydisk storing a maximum number of sectors of valid data for a host, thesolid state memory disk comprising:a) an array of nonvolatile memorydevices for storing sectors of valid data, the array including reservememory which includes free memory and dirty memory, the array beingcapable of storing a number of uncompressed sectors of valid data, eachnonvolatile memory device including a first multiplicity of blocks ofmemory; b) a microprocessor for controlling the array, themicroprocessor indicating the maximum number of sectors to the host, themaximum number being less than an average compression ratio multipliedby the number of uncompressed sectors of valid data the array is capableof storing, the microprocessor in response to a first write command fromthe host writing a first compressed sector data having a first sectornumber to a first location in a first block in the array, themicroprocessor in response to a second write command from the hostwriting a second compressed sector data having the first sector numberto a second location in a second block and marking dirty the firstcompressed sector having the first sector number; c) a clean-up machinegenerating free memory by erasing the first block after copying allcompressed sectors of valid data within the first block out of the firstblock and into another block, the clean-up machine waiting a longer timeto generate free memory than if the first block contained uncompressedsectors of valid data, thereby reducing energy consumption; and d) acompressor which has the average compression ratio, the compressor beingresponsive to the microprocessor, the compressor compressinguncompressed sectors of valid data received from the host and passingthe first compressed sector of data and the second sector of data to thearray.
 4. The solid state memory disk of claim 3 wherein the compressorin response to a read command from the host decompresses a compressedsector of data stored within the array and passes the decompressed datato the host.
 5. The solid state memory disk of claim 3 wherein themicroprocessor includes:a) allocation means for allocating a firstmultiplicity of memory locations within a selected block within thearray in response to a write command.
 6. A method of increasing reservememory in a solid state disk, the solid state disk including an array ofnonvolatile memory devices and a compressor, the array storing sectorsof valid data and including reserve memory, the reserve memory includingfree memory and dirty memory, the array being capable of storing a firstnumber of uncompressed sectors, each nonvolatile memory device includinga multiplicity of blocks of memory, the method including the steps of:a)indicating to a host a maximum number of sectors of valid data that maybe written to the solid state disk, the maximum number being equal tothe first number of uncompressed sectors the array is capable ofstoring; b) receiving a command to write a first sector of valid datafrom the host, the first sector of valid data being uncompressed,uncompressed sectors of valid data including a first number of bytes; c)compressing the first sector of valid data to produce a first compressedsector of data, the first compressed sector of data including a secondnumber of bytes, the second number of bytes being less than the firstnumber of bytes; and d) storing the first compressed sector of data in afirst block within the array.
 7. The method of claim 6 furthercomprising the step of:cleaning-up a second block within the array bycopying compressed sectors of valid data from the second block into athird block having sufficient reserve memory to store the compressedsectors of valid data from the second block.
 8. The method of claim 7further comprising the step of:evaluating whether clean-up of the solidstate memory disk is necessary and cleaning-up the second block onlywhen clean-up of the solid state memory disk is necessary.
 9. The methodof claim 8 wherein the evaluating step comprises the steps of:a)identifying a first number which is the amount of reserve memory withinthe solid state memory disk; b) comparing a second number representativeof an amount of free memory within the solid state memory disk to thefirst number; and c) deciding clean-up of the solid state memory disk isnecessary if the second number is less than or equal to the firstnumber.
 10. The method of claim 6 further comprising the stepof:decompressing the first compressed sector of data and transferringthe first sector of valid data to the host in response to a command fromthe host to read the first sector of valid data.
 11. A method ofreducing energy consumption in a solid state disk, the solid state diskincluding an array of nonvolatile memory devices and a data compressor,the array storing sectors of valid data and including reserve memory,the reserve memory including free memory and dirty memory, the arrayhaving a memory capacity of a fixed number of uncompressed sectors ofdata, each nonvolatile memory device including a multiplicity of blocksof memory, the data compressor having an average compression ratio, themethod including the steps of:a) indicating to a host a maximum numberof sectors of valid data that may be written to the solid state disk,the maximum number of sectors being less than the average compressionratio multiplied by the memory capacity; b) receiving a command to writea first sector of valid data from the host, the first sector of validdata received from the host being uncompressed and being a first numberof bytes; c) compressing the first sector of valid data received fromthe host to create a first compressed sector of valid data, the firstcompressed sector being a second number of bytes, the second number ofbytes being less than or equal to the first number of bytes; d) storingthe first compressed sector within the array; and e) cleaning-up aselected block within the array after waiting a longer time than if theselected block uncompressed sectors of valid data, thereby reducingenergy consumption the cleaning-up including the steps of:i) selecting afirst block to clean-up; ii) allocating a sufficient amount of memory ina second block to store the first compressed sector stored within thefirst block; iii) copying the first compressed sector from the firstblock into the second block; and iv) erasing the first block therebyconverting all memory within the first block into free memory.
 12. Themethod of claim 11 wherein the maximum number of sectors is greater thanthe fixed number of uncompressed sectors, the maximum number of sectorsthereby allocating to the host up to a third number of bytes whenever acompressed sector of data is stored.
 13. The method of claim 11 furthercomprising the step of:decompressing the first compressed sector of datato produce the first sector of valid data and coupling the first sectorof valid data to the host in response to a command from the host to readthe first sector of valid data.
 14. The method of claim 11 wherein thecleaning-up step further comprises the step of:evaluating whetherclean-up of the solid state memory disk is necessary and cleaning-up theselected block only when clean-up of the solid state memory disk isnecessary.
 15. The method of claim 14 wherein the evaluating stepcomprises the steps of:a) identifying a third number which is an amountof reserve memory within the solid state memory disk; b) comparing afourth number representative of an amount of free memory within thesolid state memory disk to the first number; and c) deciding clean-up ofthe solid state memory disk is necessary if the fourth number is lessthan the a selected percentage of the third number.
 16. The method ofclaim 11 wherein the selecting step comprises:a) selecting a blockhaving a greatest amount of dirty memory.
 17. The method of claim 11wherein the allocating step comprises the steps of:a) determiningwhether a compressed sector of valid data remains to be copied from thefirst block; b) identifying as the second block another block withsufficient free memory to store the compressed sector of valid data; andc) reserving sufficient memory in the second block to store thecompressed sector of valid data.
 18. A method of increasing reservememory in a solid state disk, the solid state disk including an array ofnonvolatile memory devices and a data compressor, the data compressorhaving an average compression ratio, the array storing sectors of validdata and including reserve memory, the reserve memory including freememory and dirty memory, the array having a memory capacity of a fixednumber of uncompressed sectors of data, each nonvolatile memory deviceincluding a multiplicity of blocks of memory, each block of memoryincluding a block sector translation table, each block sectortranslation table including a header for each sector of data stored inthe block, each header including a logical sector number equal to asector number with which the sector of valid data is associated, themethod including the steps of:a) indicating to a host a maximum numberof sectors of valid data that may be written to the solid state disk,the maximum number of sectors being less than the average compressionratio multiplied by the memory capacity; b) receiving a command to writea first sector of valid data from the host, the first sector of validdata received from the host being uncompressed and having a first sectornumber, the first sector of valid data from the host being a firstnumber of bytes; c) marking dirty a previously compressed sector of datastored within the array associated with a logical sector number equal tothe first sector number; d) compressing the first sector of valid datareceived from the host to create a first compressed sector of validdata, the first compressed sector being a second number of bytes that isless than the first number of bytes; e) allocating a first amount offree memory in a first block having a first block sector translationtable, the first amount of free memory being equal to the second numberof bytes; f) writing a first header for the first compressed sector intothe first block sector translation table; g) storing the firstcompressed sector within the first block; and f) cleaning-up a selectedblock within the array, cleaning-up including the steps of:i) selectinga second block to clean-up; ii) on a compressed sector by compressedsector basis:1) selecting a compressed sector from a group of compressedsectors remaining to be copied from the second block; 2) allocatingsufficient free memory to store the selected compressed sector in aselected block; 3) copying the selected compressed sector from thesecond block into the selected block; 4) repeating steps 1) through 3)until all compressed sectors within the first block have been copied;and 5) erasing the second block.
 19. The method of claim 18 wherein themaximum number of sector numbers is greater than the first fixed numberof uncompressed sectors, the maximum number thereby allocating to thehost up to a third number of bytes when a compressed sector of data isstored.
 20. The method of claim 18 further comprising the stepof:decompressing the first compressed sector of data to regenerate thefirst sector of valid data and coupling the first sector of valid datato the host in response to a command from the host to read the firstsector of valid data.
 21. The method of claim 18 wherein the cleaning-upstep further comprises the step of:evaluating whether clean-up of thesolid state memory disk is necessary and cleaning-up the selected blockonly when clean-up of the solid state memory disk is necessary.
 22. Themethod of claim 21 wherein the evaluating step comprises the steps of:a)identifying a third number which is an amount of reserve memory withinthe solid state memory disk; b) comparing a fourth number representativeof an amount of free memory within the solid state memory disk to thethird number; and c) deciding clean-up of the solid state memory disk isnecessary if the fourth number is less than the a selected percentage ofthe third number.
 23. The method of claim 18 wherein the selecting stepcomprises:a) selecting a block having a greatest amount of dirty memory.24. The method of claim 18 wherein the allocating step comprises thesteps of:a) determining whether a compressed sector of valid dataremains to be copied from the first block; b) identifying as the secondblock another block with sufficient free memory to store the compressedsector of valid data; and c) reserving sufficient memory in the secondblock to store the compressed sector of valid data.